Project import
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..66bdca2 --- /dev/null +++ b/Makefile
@@ -0,0 +1,142 @@ +# +# Copyright (c) 2015 Nest, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file is the make file for neard, a daemon that connects +# user applications to the NFC kernel drivers. +# + +BuildConfigSpecialized := No +BuildProductSpecialized := No + +include pre.mak + +PackageRoot := . + +PackageName := neard + +PackageSeparator := + +PackageSourceDir := $(PackageRoot)/$(PackageName) + +PackageBuildMakefile = $(call GenerateBuildPaths,Makefile) + +LicenseSourceFile := $(PackageSourceDir)/COPYING + +CleanPaths += $(PackageLicenseFile) + +DbusDir := sw/tps/dbus +DbusIncDirs := $(call GenerateResultPaths,$(DbusDir),usr/include/dbus-1.0 usr/lib/dbus-1.0/include) +DbusLibDir := $(call GenerateResultPaths,$(DbusDir),usr/lib) + +GlibDir := sw/tps/glib +GlibIncDirs := $(call GenerateResultPaths,$(GlibDir),usr/include/glib-2.0 usr/lib/glib-2.0/include) +GlibLibDir := $(call GenerateResultPaths,$(GlibDir),usr/lib) + +GnuTlsDir := sw/tps/gnutls +GnuTlsIncDir := $(call GenerateResultPaths,$(GnuTlsDir),usr/include) +GnuTlsLibDir := $(call GenerateResultPaths,$(GnuTlsDir),usr/lib) + +LibnlDir := sw/tps/libnl +LibnlIncDir := $(call GenerateResultPaths,$(LibnlDir),usr/include/ usr/lib/include) +LibnlLibDir := $(call GenerateResultPaths,$(LibnlDir),usr/lib) + +LinuxDir := sw/tps/linux +LinuxIncDir := $(call GenerateResultPaths,$(LinuxDir),include) + + +all: $(PackageDefaultGoal) + +# Generate the package license contents. + +$(LicenseSourceFile): source + +$(PackageLicenseFile): $(LicenseSourceFile) + $(copy-result) + +# We are building this package from version-controlled source, so +# there is nothing to do for this target goal. + +$(PackageSourceDir): + +# Prepare the sources. + +.PHONY: source +source: | $(PackageSourceDir) + +# Patch the sources, if necessary. + +.PHONY: patch +patch: source + +# Generate the package build makefile. + +OPTIONS_FLAGS = \ + --disable-systemd \ + --enable-debug \ + --enable-test \ + --enable-tools + +$(PackageBuildMakefile): | $(PackageSourceDir) $(BuildDirectory) $(ResultDirectory) + $(Verbose)cd $(BuildDirectory) && \ + $(CURDIR)/$(PackageSourceDir)/configure \ + INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ + CC="$(CC)" CXX="$(CXX)" AR=$(AR) NM=$(NM) RANLIB=$(RANLIB) STRIP=$(STRIP) \ + CPPFLAGS="$(call ToolGenerateIncludeArgument,$(LinuxIncDir))" \ + LDFLAGS=" " \ + DBUS_CFLAGS="$(call ToolGenerateIncludeArgument,$(DbusIncDirs))" \ + DBUS_LIBS="-L$(DbusLibDir) -ldbus-1" \ + GLIB_CFLAGS="$(call ToolGenerateIncludeArgument,$(GlibIncDirs))" \ + GLIB_LIBS="-L$(GlibLibDir) -lglib-2.0" \ + LIBNL2_CFLAGS="$(call ToolGenerateIncludeArgument,$(LibnlIncDir))" \ + LIBNL2_LIBS="-L$(LibnlLibDir) -lnl -lnl-genl" \ + GNUTLS_CFLAGS="$(call ToolGenerateIncludeArgument,$(GnuTlsIncDir))" \ + GNUTLS_LIBS="-L$(GnuTlsLibDir) -lgnutls -Wl,-rpath-link -Wl,$(GpgErrorLibDir) -Wl,-rpath-link -Wl,$(GcryptLibDir)" \ + GTHREAD_CFLAGS="$(call ToolGenerateIncludeArgument,$(GlibIncDirs))" \ + GTHREAD_LIBS="-L$(GlibLibDir) -lgthread-2.0" \ + --build=$(HostTuple) \ + --host=$(TargetTuple) \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + $(OPTIONS_FLAGS) + +# Configure the source for building. + +.PHONY: configure +configure: source $(PackageBuildMakefile) + +# Build the source. +# +# We have to unset MAKEFLAGS since they confuse the package build otherwise. + +.PHONY: build +build: configure + $(Verbose)unset MAKEFLAGS && \ + $(MAKE) $(JOBSFLAG) -C $(BuildDirectory) \ + all + +# Stage the build to a temporary installation area. +# +# We have to unset MAKEFLAGS since they confuse the package build otherwise. + +.PHONY: stage +stage: build | $(ResultDirectory) + $(Verbose)unset MAKEFLAGS && \ + $(MAKE) $(JOBSFLAG) -C $(BuildDirectory) \ + DESTDIR=$(ResultDirectory) \ + install + +clean: + $(Verbose)$(RM) $(RMFLAGS) -r $(BuildDirectory) + $(Verbose)$(RM) $(RMFLAGS) -r $(ResultDirectory) + +include post.mak
diff --git a/neard.url b/neard.url new file mode 100644 index 0000000..fa00749 --- /dev/null +++ b/neard.url
@@ -0,0 +1 @@ +git://git.kernel.org/pub/scm/network/nfc/neard.git
diff --git a/neard.version b/neard.version new file mode 100644 index 0000000..2856407 --- /dev/null +++ b/neard.version
@@ -0,0 +1 @@ +0.15
diff --git a/neard/.mailmap b/neard/.mailmap new file mode 100644 index 0000000..f02e1dd --- /dev/null +++ b/neard/.mailmap
@@ -0,0 +1 @@ +Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com> <ravikumar.veeramally@linux.intel.com>
diff --git a/neard/AUTHORS b/neard/AUTHORS new file mode 100644 index 0000000..fa489fa --- /dev/null +++ b/neard/AUTHORS
@@ -0,0 +1,23 @@ +Samuel Ortiz <sameo@linux.intel.com> +Marcel Holtmann <marcel@holtmann.org> +Olivier Guiter <olivier.guiter@linux.intel.com> +Ravikumar Veeramally <ravikumar.veeramally@linux.intel.com> +Vinicius Costa Gomes <vcgomes@gmail.com> +Eyal Reizer <eyalr@ti.com> +Jeff Zheng <jeff.zheng@linux.intel.com> +Szymon Janc <szymon.janc@tieto.com> +Wiktor Lawski <wiktor.lawski@tieto.com> +Dorota Moskal <dorota.moskal@tieto.com> +Krzysztof Lyczkowski <krzysztof.lyczkowski@tieto.com> +Christophe Prigent <christophe.prigent@intel.com> +Marcin MaĆagowski <marcin.malagowski@mobica.com> +Guillem Jover <guillem@hadrons.org> +Marcin Malagowski <marcin.malagowski@mobica.com> +Louis Yung-Chieh Lo <yjlou@google.com> +Daniel Wagner <daniel.wagner@bmw-carit.de> +Dmytro Bagrii <dimich@softerra.com> +Timo Mueller <timo.mueller@bmw-carit.de> +Al Yu-Chen, Cho <acho@suse.com> +Mark A. Greer <mgreer@animalcreek.com> +Arron Wang <arron.wang@intel.com> +Vincent Cuissard <cuissard@marvell.com>
diff --git a/neard/COPYING b/neard/COPYING new file mode 100644 index 0000000..6d45519 --- /dev/null +++ b/neard/COPYING
@@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, 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 Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 St, 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. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License.
diff --git a/neard/ChangeLog b/neard/ChangeLog new file mode 100644 index 0000000..c11be76 --- /dev/null +++ b/neard/ChangeLog
@@ -0,0 +1,152 @@ +ver 0.15 + Added iso15693 (NFC type5) support. + Added Secure Element support (seeld). + Added iso14443-B (NFC type4b) support. + Added NFC type5 RMB (Read Multiple Block) support. + Fixed NFC type1 dynamic read. + Fixed NFC type1 check_presence to only read the tag ID. + Fixed NFC type2 CC magic number check. + Fixed NFC type4 NDEF detection and handling code. + Fixed NFC type4 check_presence implementation. + Fixed PHDC coding style and potential bugs. + Fixed the constant poll loop to retry on busy adapters. + Fixed an agent memory leak. + Fixed and cleaned the build system. + +ver 0.14 + Added a Tag and Device Adapter property. + Added NDEF agent record payload getter. + Added support for catching poll errors. + Added ObjectManager API support. + Added NPP push support. + Added simplified test scripts. + Fixed a t4t write bug. + Fixed NPP read. + Fixed security bugs. + +ver 0.13 + Added PHDC Manager support. + Added nfctool firmware update support. + Added AAR NDEF support. + Added raw MIME type payload support. + Added multibyte handover CDR support. + Fixed coding style for NULL pointer and 0 checks. + Fixed a t4t memory leak. + Fixed a t1t capability container reading offset. + Fixed a handover memory leak. + +ver 0.12 + Added static handover through LLCP support. + Added WiFi configuration handover through SNEP support. + Added nfctool SNEP decoding. + Added nfctool Handover decoding. + Added nfctool output coloring support. + Added type4B tag support. + Added p2p non blocking client socket support. + Fixed SNEP fragmentation support. + Fixed a type3 tag crash. + Fixed a bluetooth crash. + Fixed NFC bugs #45 and #48. + +ver 0.11 + Added LLCP validation server support. + Added SNEP unit tests. + Added nfctool man page. + Added WiFi WSC NDEF building support. + Fixed AGF nfctool support. + Fixed type2 tag data length handling. + Fixed pkg-config libnl dependencies. + Fixed SNEP validation code for ARM. + +ver 0.10 + Added initial WiFi handover support. + Added Service Name Lookup support to nfctool. + Added NDEF building unit tests. + Added State support to Bluetooth handover agent. + Added neard and neard.conf man pages. + Added a copy of the NFC kernel header. + Fixed handover validation tests failures. + Fixed Tag and Device PropertyChanged signal. + +ver 0.9 + Added NDEF unit tests. + Added SNEP validation server support. + Added nfctool command line uility. + Added Bluetooth handover agent implementation. + Fixed build for several architectures. + Fixed p2p fallback mechanism. + Fixed Type3 tag reading default behaviour. + +ver 0.8 + Added raw NDEF push through the NDEF agent API. + Fixed a couple of p2p file descriptor leaks. + Fixed CR handover record handling in handover Select frames. + Fixed handover version check support. + Fixed handover code to support AC less frames. + Fixed p2p client event routine to support multiple incoming requests. + Fixed netlink support for nested events. + +ver 0.7 + Added support for Android Jelly Bean handover. + Added a Bluetooth handover automated script. + Added MIFARE Classic writing support. + Added MIFARE read only check support. + Added MIFARE check presence support. + Fixed a tag writing related double free. + Fixed tag plugins memory leaks. + Fixed tag plugins callback calls code paths. + Fixed URI NDEF writing. + +ver 0.6 + Added tag formatting support for Type 1, 3 an 4. + Added blank tag detection for Type 1, 3 and 4. + Added an NDEF agent API implementation. + Fixed the handover agent API. + Fixed potential NULL pointer dereferences. + Fixed a few plugin memory leaks. + Fixed p2p NDEF push while p2p link is down. + +ver 0.5: + Added Handover Initiator support. + Added Handover selector support. + Added support for Type 2 tags formatting. + Added early binding support. + Fixed handover and p2p memory leaks. + Fixed Type 2 tag read command. + Fixed NDEF push return value. + Removed plugins enablement configure options. + +ver 0.4: + Added target mode support for peer to peer. + Added a handover agent API. + Fixed SNEP read fragmentation. + Fixed SNEP response frames version field. + Fixed build dependencies. + Fixed netlink and adapter memory leaks. + +ver 0.3: + Added a Tag D-Bus API. + Added an SNEP testing tool. + Added SNEP fragmentation support. + Added BlueZ signal handlers for adapter tracking. + Added BlueZ adapter properties handling. + Added a main.conf template. + Removed the Target D-Bus API. + Fixed Type 1 commands handling. + +ver 0.2: + Added SNEP support. + Added tag presence check implementation. + Added initial publishing API implementation. + Added MIFARE reader support. + Added NFC type 3 writer mode support. + Added netlink Powered property handling implementation. + Fixed p2p network conditions errors. + Fixed valgrind memory leak reports. + +ver 0.1: + Added reader mode for NFC types 1,2,3 and 4. + Added writer mode for NFC types 1,2, and 4. + Added peer to peer reader mode (NPP). + Added initial SNEP support. + Added initial Bluetooth OOB support.
diff --git a/neard/HACKING b/neard/HACKING new file mode 100644 index 0000000..478653c --- /dev/null +++ b/neard/HACKING
@@ -0,0 +1,87 @@ +Hacking on Near Field Communication manager +******************************************* + + +Build tools requirements +======================== + +When building and testing directly from the repository it is important to +have at least automake version 1.10 or later installed. All modern +distributions should default to the latest version, but it seems that +Debian's default is still an earlier version: + + Check version + # dpkg -l '*automake*' + + Install new version + # apt-get install automake1.10 + # update-alternatives --config automake + + +Working with the source code repository +======================================= + +The repository contains two extra scripts that accomplish the bootstrap +process. One is called "bootstrap" which is the basic scripts that uses the +autotools scripts to create the needed files for building and installing. +It makes sure to call the right programs depending on the usage of shared or +static libraries or translations etc. + +The second program is called "bootstrap-configure". This program will make +sure to properly clean the repository, call the "bootstrap" script and then +call configure with proper settings for development. It will use the best +options and pass them over to configure. These options normally include +the enabling the maintainer mode and the debugging features. + +So while in a normal source project the call "./configure ..." is used to +configure the project with its settings like prefix and extra options. In +case of bare repositories call "./bootstrap-configure" and it will bootstrap +the repository and calls configure with all the correct options to make +development easier. + +In case of preparing for a release with "make distcheck", don't use +bootstrap-configure since it could export development specific settings. + +So the normal steps to checkout, build and install such a repository is +like this: + + Checkout repository + # git clone git://git.kernel.org/pub/scm/network/.../neard.git + # cd neard + + Configure and build + # ./bootstrap-configure + # make + + Check installation + # make install DESTDIR=$PWD/x + # find x + # rm -rf x + + Check distribution + # make distcheck + + Final installation + # sudo make install + + Remove autogenerated files + # make maintainer-clean + + +Running from within the source code repository +============================================== + +When using "./configure --enable-maintainer-mode" the automake scripts will +use the plugins directly from within the repository. This removes the need +to use "make install" when testing "neard". The "bootstrap-configure" +automatically includes this option. + + Run daemon in foreground with debugging + # ./src/neard -n -d 'src/*' + +For production installations or distribution packaging it is important that +the "--enable-maintainer-mode" option is NOT used. + +The debugging option -d takes an argument. This argument can be a comma +separated list of file names like 'src/main.c,src/manager.c' to enable debugs +in these files. Simple glob style pattern matching is supported in this list.
diff --git a/neard/INSTALL b/neard/INSTALL new file mode 100644 index 0000000..56b077d --- /dev/null +++ b/neard/INSTALL
@@ -0,0 +1,236 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free +Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + +By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PREFIX', the package will +use PREFIX as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). Here is a another example: + + /bin/bash ./configure CONFIG_SHELL=/bin/bash + +Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent +configuration-related scripts to be executed by `/bin/bash'. + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. +
diff --git a/neard/Makefile.am b/neard/Makefile.am new file mode 100644 index 0000000..a6f8221 --- /dev/null +++ b/neard/Makefile.am
@@ -0,0 +1,274 @@ + +ACLOCAL_AMFLAGS = -I m4 + +AM_MAKEFLAGS = --no-print-directory + +pkgincludedir = ${includedir}/near + +pkginclude_HEADERS = include/types.h include/log.h include/plugin.h \ + include/tag.h include/adapter.h include/ndef.h \ + include/tlv.h include/setting.h include/device.h \ + include/nfc_copy.h include/snep.h + +nodist_include_HEADERS = include/version.h + +noinst_HEADERS = include/dbus.h + +local_headers = $(foreach file,$(pkginclude_HEADERS) $(nodist_include_HEADERS) \ + $(noinst_HEADERS), include/near/$(notdir $(file))) + +gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/watch.c \ + gdbus/object.c gdbus/client.c gdbus/polkit.c + +plugin_LTLIBRARIES = + +plugin_objects = + +unit_objects = + +builtin_modules = +builtin_sources = +builtin_cflags = +builtin_libadd = + +bin_PROGRAMS = + +pkglibexecdir = ${libexecdir}/nfc +pkglibexec_PROGRAMS = src/neard + +src_neard_SOURCES = $(gdbus_sources) $(gweb_sources) $(builtin_sources) \ + src/main.c src/error.c src/near.h src/log.c \ + src/dbus.c src/manager.c src/adapter.c src/device.c \ + src/tag.c src/plugin.c src/netlink.c src/ndef.c \ + src/tlv.c src/bluetooth.c src/agent.c src/snep.c + +src_neard_LDADD = $(builtin_libadd) ${GLIB_LIBS} ${DBUS_LIBS} ${NETLINK_LIBS} -ldl + +src_neard_LDFLAGS = -Wl,--export-dynamic + +src_neard_DEPENDENCIES= src/neard.service + +BUILT_SOURCES = src/builtin.h + +AM_CPPFLAGS = ${GLIB_CFLAGS} ${DBUS_CFLAGS} ${NETLINK_CFLAGS} \ + -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""$(plugindir)"\" \ + -DCONFIGDIR=\""$(configdir)\"" \ + -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus + +AM_CFLAGS = ${builtin_cflags} -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus + +if SE + +se_plugin_LTLIBRARIES = + +se_plugin_objects = + +builtin_se_modules = +builtin_se_sources = +builtin_se_libadd = +builtin_se_cflags = + +pkglibexec_PROGRAMS += se/seeld + +se_seeld_SOURCES = $(gdbus_sources) $(builtin_se_sources) \ + src/log.c src/dbus.c src/error.c src/plugin.c \ + se/main.c se/seel.h se/manager.c se/manager.h \ + se/se.c se/driver.c se/driver.h se/apdu.c \ + se/channel.c se/ace.c + +se_seeld_LDADD = $(builtin_se_libadd) @GLIB_LIBS@ @DBUS_LIBS@ -ldl + +se_seeld_LDFLAGS = -Wl,--export-dynamic + +BUILT_SOURCES += se/builtin.h +endif + +src_neard_CFLAGS = ${builtin_cflags} -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus + +src_neard_CPPFLAGS = ${GLIB_CFLAGS} ${DBUS_CFLAGS} ${NETLINK_CFLAGS} \ + -DNEAR_PLUGIN_BUILTIN \ + -DPLUGINDIR=\""$(plugindir)"\" \ + -DCONFIGDIR=\""$(configdir)\"" \ + -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus + +if SE +src_seeld_CFLAGS = ${builtin_se_cflags} -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus + +se_seeld_CPPFLAGS = ${GLIB_CFLAGS} ${DBUS_CFLAGS} ${NETLINK_CFLAGS} \ + -DNEAR_PLUGIN_BUILTIN \ + -DPLUGINDIR=\""$(build_se_plugindir)"\" \ + -DCONFIGDIR=\""$(configdir)\"" \ + -I$(builddir)/se +endif + +CLEANFILES = src/builtin.h se/builtin.h $(local_headers) + +configdir = ${sysconfdir}/neard + +dist_noinst_DATA = src/main.conf + +dbusdir = ${sysconfdir}/dbus-1/system.d/ + +dist_dbus_DATA = src/org.neard.conf + +if MAINTAINER_MODE + +if SE +build_se_plugindir = $(abs_top_srcdir)/se/plugins/.libs +endif + +build_plugindir = $(abs_top_srcdir)/plugins/.libs + +else + +if SE +build_se_plugindir = $(se_plugindir) +endif + +build_plugindir = $(plugindir) +endif + +doc_files = doc/tag-api.txt doc/device-api.txt doc/adapter-api.txt \ + doc/agent-api.txt doc/phdc-api.txt \ + doc/secureelement-api.txt doc/se-manager-api.txt + +EXTRA_DIST = src/genbuiltin $(doc_files) + +dist_man_MANS = doc/neard.8 doc/neard.conf.5 doc/nfctool.1 + +test_scripts = test/test-adapter test/test-device \ + test/test-tag test/monitor-near test/bt-handover \ + test/handover-agent test/phdc-simple-manager \ + test/neardutils.py + +if SYSTEMD +systemdsystemunitdir = ${SYSTEMD_SYSTEMUNITDIR} +systemdsystemunit_DATA = src/neard.service +endif + +EXTRA_DIST += src/neard.service.in +CLEANFILES += src/neard.service + +if TEST +testdir = $(pkglibdir)/test +test_SCRIPTS = $(test_scripts) +endif + +if TOOLS +bin_PROGRAMS += tools/nfctool/nfctool + +noinst_PROGRAMS = tools/snep-send + +tools_snep_send_SOURCES = $(gdbus_sources) src/log.c src/dbus.c \ + src/bluetooth.c src/ndef.c \ + tools/snep-send.c src/error.c \ + src/agent.c +tools_snep_send_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} + +tools_nfctool_nfctool_SOURCES = $(gdbus_sources) tools/nfctool/main.c \ + tools/nfctool/nfctool.h \ + tools/nfctool/adapter.h \ + tools/nfctool/adapter.c \ + tools/nfctool/netlink.h \ + tools/nfctool/netlink.c \ + tools/nfctool/sniffer.h \ + tools/nfctool/sniffer.c \ + tools/nfctool/llcp-decode.h \ + tools/nfctool/llcp-decode.c \ + tools/nfctool/snep-decode.h \ + tools/nfctool/snep-decode.c \ + tools/nfctool/ndef-decode.h \ + tools/nfctool/ndef-decode.c \ + tools/nfctool/display.h \ + tools/nfctool/display.c \ + src/log.c src/dbus.c \ + src/bluetooth.c src/ndef.c \ + src/error.c src/agent.c + + +tools_nfctool_nfctool_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} ${NETLINK_LIBS} +endif + +tools_nfctool_nfctool_CPPFLAGS = ${GLIB_CFLAGS} ${DBUS_CFLAGS} ${NETLINK_CFLAGS} \ + -DNEAR_PLUGIN_BUILTIN \ + -DPLUGINDIR=\""$(plugindir)"\" \ + -DCONFIGDIR=\""$(configdir)\"" \ + -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus + +unit_tests = unit/test-ndef-parse unit/test-ndef-build unit/test-snep-read + +unit_test_ndef_parse_SOURCES = $(gdbus_sources) src/log.c src/dbus.c \ + src/error.c src/agent.c \ + src/bluetooth.c src/ndef.c \ + unit/test-ndef-parse.c +unit_test_ndef_parse_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} + +unit_test_ndef_build_SOURCES = $(gdbus_sources) src/log.c src/dbus.c \ + src/error.c src/agent.c \ + src/bluetooth.c src/ndef.c \ + unit/test-ndef-build.c +unit_test_ndef_build_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} + +unit_test_snep_read_SOURCES = $(gdbus_sources) src/log.c src/dbus.c \ + src/error.c src/agent.c \ + src/bluetooth.c src/ndef.c src/snep.c \ + unit/test-snep-read.c unit/test-utils.c \ + unit/test-utils.h +unit_test_snep_read_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} + +check_PROGRAMS = $(unit_tests) + +TESTS = $(unit_tests) + +include Makefile.plugins + +EXTRA_DIST += $(test_scripts) + +pkgconfigdir = $(libdir)/pkgconfig + +pkgconfig_DATA = neard.pc + +DISTCHECK_CONFIGURE_FLAGS = --enable-tools --enable-ese --disable-systemd + +DISTCLEANFILES = $(pkgconfig_DATA) + +MAINTAINERCLEANFILES = Makefile.in \ + aclocal.m4 configure config.h.in config.sub config.guess \ + ltmain.sh depcomp compile missing install-sh mkinstalldirs + +SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \ + $(SED) -e 's,@pkglibexecdir\@,$(pkglibexecdir),g' \ + < $< > $@ + +%.service: %.service.in Makefile + $(SED_PROCESS) + +src/plugin.$(OBJEXT): src/builtin.h + +src/builtin.h: src/genbuiltin $(builtin_sources) + $(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@ + +se/plugin.$(OBJEXT): se/builtin.h + +se/builtin.h: src/genbuiltin $(builtin_se_sources) + $(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_se_modules) > $@ + +$(src_neard_OBJECTS) \ +$(tools_nfctool_nfctool_OBJECTS) \ +$(plugin_objects) \ +$(se_seeld_OBJECTS) \ +$(unit_test_ndef_parse_OBJECTS) \ +$(unit_test_ndef_build_OBJECTS) \ +$(unit_test_snep-read_OBJECTS) \ +$(tools_snep_send_OBJECTS): $(local_headers) + +include/near/version.h: include/version.h + $(AM_V_at)$(MKDIR_P) include/near + $(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$< $@ + +include/near/%.h: $(abs_top_srcdir)/include/%.h + $(AM_V_at)$(MKDIR_P) include/near + $(AM_V_GEN)$(LN_S) $< $@ + +clean-local: + @$(RM) -rf include/near
diff --git a/neard/Makefile.in b/neard/Makefile.in new file mode 100644 index 0000000..49dd6be --- /dev/null +++ b/neard/Makefile.in
@@ -0,0 +1,3384 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 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@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@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@ +bin_PROGRAMS = $(am__EXEEXT_1) +pkglibexec_PROGRAMS = src/neard$(EXEEXT) $(am__EXEEXT_3) +@SE_TRUE@am__append_1 = se/seeld +@SE_TRUE@am__append_2 = se/builtin.h +@TOOLS_TRUE@am__append_3 = tools/nfctool/nfctool +@TOOLS_TRUE@noinst_PROGRAMS = tools/snep-send$(EXEEXT) +check_PROGRAMS = $(am__EXEEXT_2) +TESTS = $(am__EXEEXT_2) +DIST_COMMON = $(srcdir)/Makefile.plugins $(srcdir)/Makefile.in \ + $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(srcdir)/config.h.in \ + $(top_srcdir)/include/version.h.in $(srcdir)/neard.pc.in \ + depcomp $(dist_man_MANS) $(dist_dbus_DATA) $(dist_noinst_DATA) \ + $(noinst_HEADERS) $(pkginclude_HEADERS) test-driver AUTHORS \ + COPYING ChangeLog INSTALL NEWS README TODO compile \ + config.guess config.sub install-sh missing ltmain.sh +@NFCTYPE1_TRUE@am__append_4 = nfctype1 +@NFCTYPE1_TRUE@am__append_5 = plugins/nfctype1.c +@NFCTYPE2_TRUE@am__append_6 = nfctype2 +@NFCTYPE2_TRUE@am__append_7 = plugins/nfctype2.c plugins/mifare.c +@NFCTYPE3_TRUE@am__append_8 = nfctype3 +@NFCTYPE3_TRUE@am__append_9 = plugins/nfctype3.c +@NFCTYPE4_TRUE@am__append_10 = nfctype4 +@NFCTYPE4_TRUE@am__append_11 = plugins/nfctype4.c +@NFCTYPE5_TRUE@am__append_12 = nfctype5 +@NFCTYPE5_TRUE@am__append_13 = plugins/nfctype5.c +@P2P_TRUE@am__append_14 = p2p +@P2P_TRUE@am__append_15 = plugins/p2p.c plugins/npp.c \ +@P2P_TRUE@ plugins/snep.c \ +@P2P_TRUE@ plugins/snep-validation.c \ +@P2P_TRUE@ plugins/llcp-validation.c \ +@P2P_TRUE@ plugins/handover.c plugins/p2p.h \ +@P2P_TRUE@ plugins/phdc.c + +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = include/version.h neard.pc +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__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(se_plugindir)" \ + "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkglibexecdir)" \ + "$(DESTDIR)$(testdir)" "$(DESTDIR)$(man1dir)" \ + "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)" \ + "$(DESTDIR)$(dbusdir)" "$(DESTDIR)$(pkgconfigdir)" \ + "$(DESTDIR)$(systemdsystemunitdir)" "$(DESTDIR)$(includedir)" \ + "$(DESTDIR)$(pkgincludedir)" +LTLIBRARIES = $(plugin_LTLIBRARIES) $(se_plugin_LTLIBRARIES) +@TOOLS_TRUE@am__EXEEXT_1 = tools/nfctool/nfctool$(EXEEXT) +am__EXEEXT_2 = unit/test-ndef-parse$(EXEEXT) \ + unit/test-ndef-build$(EXEEXT) unit/test-snep-read$(EXEEXT) +@SE_TRUE@am__EXEEXT_3 = se/seeld$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(pkglibexec_PROGRAMS) +am__se_seeld_SOURCES_DIST = gdbus/gdbus.h gdbus/mainloop.c \ + gdbus/watch.c gdbus/object.c gdbus/client.c gdbus/polkit.c \ + se/plugins/nfc.c src/log.c src/dbus.c src/error.c src/plugin.c \ + se/main.c se/seel.h se/manager.c se/manager.h se/se.c \ + se/driver.c se/driver.h se/apdu.c se/channel.c se/ace.c +am__dirstamp = $(am__leading_dot)dirstamp +am__objects_1 = gdbus/se_seeld-mainloop.$(OBJEXT) \ + gdbus/se_seeld-watch.$(OBJEXT) gdbus/se_seeld-object.$(OBJEXT) \ + gdbus/se_seeld-client.$(OBJEXT) \ + gdbus/se_seeld-polkit.$(OBJEXT) +@SE_TRUE@am__objects_2 = se/plugins/se_seeld-nfc.$(OBJEXT) +@SE_TRUE@am_se_seeld_OBJECTS = $(am__objects_1) $(am__objects_2) \ +@SE_TRUE@ src/se_seeld-log.$(OBJEXT) \ +@SE_TRUE@ src/se_seeld-dbus.$(OBJEXT) \ +@SE_TRUE@ src/se_seeld-error.$(OBJEXT) \ +@SE_TRUE@ src/se_seeld-plugin.$(OBJEXT) \ +@SE_TRUE@ se/se_seeld-main.$(OBJEXT) \ +@SE_TRUE@ se/se_seeld-manager.$(OBJEXT) \ +@SE_TRUE@ se/se_seeld-se.$(OBJEXT) se/se_seeld-driver.$(OBJEXT) \ +@SE_TRUE@ se/se_seeld-apdu.$(OBJEXT) \ +@SE_TRUE@ se/se_seeld-channel.$(OBJEXT) \ +@SE_TRUE@ se/se_seeld-ace.$(OBJEXT) +se_seeld_OBJECTS = $(am_se_seeld_OBJECTS) +am__DEPENDENCIES_1 = +@SE_TRUE@se_seeld_DEPENDENCIES = $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +se_seeld_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(se_seeld_LDFLAGS) $(LDFLAGS) -o $@ +am__src_neard_SOURCES_DIST = gdbus/gdbus.h gdbus/mainloop.c \ + gdbus/watch.c gdbus/object.c gdbus/client.c gdbus/polkit.c \ + plugins/nfctype1.c plugins/nfctype2.c plugins/mifare.c \ + plugins/nfctype3.c plugins/nfctype4.c plugins/nfctype5.c \ + plugins/p2p.c plugins/npp.c plugins/snep.c \ + plugins/snep-validation.c plugins/llcp-validation.c \ + plugins/handover.c plugins/p2p.h plugins/phdc.c src/main.c \ + src/error.c src/near.h src/log.c src/dbus.c src/manager.c \ + src/adapter.c src/device.c src/tag.c src/plugin.c \ + src/netlink.c src/ndef.c src/tlv.c src/bluetooth.c src/agent.c \ + src/snep.c +am__objects_3 = gdbus/src_neard-mainloop.$(OBJEXT) \ + gdbus/src_neard-watch.$(OBJEXT) \ + gdbus/src_neard-object.$(OBJEXT) \ + gdbus/src_neard-client.$(OBJEXT) \ + gdbus/src_neard-polkit.$(OBJEXT) +@NFCTYPE1_TRUE@am__objects_4 = plugins/src_neard-nfctype1.$(OBJEXT) +@NFCTYPE2_TRUE@am__objects_5 = plugins/src_neard-nfctype2.$(OBJEXT) \ +@NFCTYPE2_TRUE@ plugins/src_neard-mifare.$(OBJEXT) +@NFCTYPE3_TRUE@am__objects_6 = plugins/src_neard-nfctype3.$(OBJEXT) +@NFCTYPE4_TRUE@am__objects_7 = plugins/src_neard-nfctype4.$(OBJEXT) +@NFCTYPE5_TRUE@am__objects_8 = plugins/src_neard-nfctype5.$(OBJEXT) +@P2P_TRUE@am__objects_9 = plugins/src_neard-p2p.$(OBJEXT) \ +@P2P_TRUE@ plugins/src_neard-npp.$(OBJEXT) \ +@P2P_TRUE@ plugins/src_neard-snep.$(OBJEXT) \ +@P2P_TRUE@ plugins/src_neard-snep-validation.$(OBJEXT) \ +@P2P_TRUE@ plugins/src_neard-llcp-validation.$(OBJEXT) \ +@P2P_TRUE@ plugins/src_neard-handover.$(OBJEXT) \ +@P2P_TRUE@ plugins/src_neard-phdc.$(OBJEXT) +am__objects_10 = $(am__objects_4) $(am__objects_5) $(am__objects_6) \ + $(am__objects_7) $(am__objects_8) $(am__objects_9) +am_src_neard_OBJECTS = $(am__objects_3) $(am__objects_10) \ + src/src_neard-main.$(OBJEXT) src/src_neard-error.$(OBJEXT) \ + src/src_neard-log.$(OBJEXT) src/src_neard-dbus.$(OBJEXT) \ + src/src_neard-manager.$(OBJEXT) \ + src/src_neard-adapter.$(OBJEXT) src/src_neard-device.$(OBJEXT) \ + src/src_neard-tag.$(OBJEXT) src/src_neard-plugin.$(OBJEXT) \ + src/src_neard-netlink.$(OBJEXT) src/src_neard-ndef.$(OBJEXT) \ + src/src_neard-tlv.$(OBJEXT) src/src_neard-bluetooth.$(OBJEXT) \ + src/src_neard-agent.$(OBJEXT) src/src_neard-snep.$(OBJEXT) +src_neard_OBJECTS = $(am_src_neard_OBJECTS) +src_neard_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(src_neard_CFLAGS) \ + $(CFLAGS) $(src_neard_LDFLAGS) $(LDFLAGS) -o $@ +am__tools_nfctool_nfctool_SOURCES_DIST = gdbus/gdbus.h \ + gdbus/mainloop.c gdbus/watch.c gdbus/object.c gdbus/client.c \ + gdbus/polkit.c tools/nfctool/main.c tools/nfctool/nfctool.h \ + tools/nfctool/adapter.h tools/nfctool/adapter.c \ + tools/nfctool/netlink.h tools/nfctool/netlink.c \ + tools/nfctool/sniffer.h tools/nfctool/sniffer.c \ + tools/nfctool/llcp-decode.h tools/nfctool/llcp-decode.c \ + tools/nfctool/snep-decode.h tools/nfctool/snep-decode.c \ + tools/nfctool/ndef-decode.h tools/nfctool/ndef-decode.c \ + tools/nfctool/display.h tools/nfctool/display.c src/log.c \ + src/dbus.c src/bluetooth.c src/ndef.c src/error.c src/agent.c +am__objects_11 = gdbus/tools_nfctool_nfctool-mainloop.$(OBJEXT) \ + gdbus/tools_nfctool_nfctool-watch.$(OBJEXT) \ + gdbus/tools_nfctool_nfctool-object.$(OBJEXT) \ + gdbus/tools_nfctool_nfctool-client.$(OBJEXT) \ + gdbus/tools_nfctool_nfctool-polkit.$(OBJEXT) +@TOOLS_TRUE@am_tools_nfctool_nfctool_OBJECTS = $(am__objects_11) \ +@TOOLS_TRUE@ tools/nfctool/tools_nfctool_nfctool-main.$(OBJEXT) \ +@TOOLS_TRUE@ tools/nfctool/tools_nfctool_nfctool-adapter.$(OBJEXT) \ +@TOOLS_TRUE@ tools/nfctool/tools_nfctool_nfctool-netlink.$(OBJEXT) \ +@TOOLS_TRUE@ tools/nfctool/tools_nfctool_nfctool-sniffer.$(OBJEXT) \ +@TOOLS_TRUE@ tools/nfctool/tools_nfctool_nfctool-llcp-decode.$(OBJEXT) \ +@TOOLS_TRUE@ tools/nfctool/tools_nfctool_nfctool-snep-decode.$(OBJEXT) \ +@TOOLS_TRUE@ tools/nfctool/tools_nfctool_nfctool-ndef-decode.$(OBJEXT) \ +@TOOLS_TRUE@ tools/nfctool/tools_nfctool_nfctool-display.$(OBJEXT) \ +@TOOLS_TRUE@ src/tools_nfctool_nfctool-log.$(OBJEXT) \ +@TOOLS_TRUE@ src/tools_nfctool_nfctool-dbus.$(OBJEXT) \ +@TOOLS_TRUE@ src/tools_nfctool_nfctool-bluetooth.$(OBJEXT) \ +@TOOLS_TRUE@ src/tools_nfctool_nfctool-ndef.$(OBJEXT) \ +@TOOLS_TRUE@ src/tools_nfctool_nfctool-error.$(OBJEXT) \ +@TOOLS_TRUE@ src/tools_nfctool_nfctool-agent.$(OBJEXT) +tools_nfctool_nfctool_OBJECTS = $(am_tools_nfctool_nfctool_OBJECTS) +@TOOLS_TRUE@tools_nfctool_nfctool_DEPENDENCIES = \ +@TOOLS_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +@TOOLS_TRUE@ $(am__DEPENDENCIES_1) +am__tools_snep_send_SOURCES_DIST = gdbus/gdbus.h gdbus/mainloop.c \ + gdbus/watch.c gdbus/object.c gdbus/client.c gdbus/polkit.c \ + src/log.c src/dbus.c src/bluetooth.c src/ndef.c \ + tools/snep-send.c src/error.c src/agent.c +am__objects_12 = gdbus/mainloop.$(OBJEXT) gdbus/watch.$(OBJEXT) \ + gdbus/object.$(OBJEXT) gdbus/client.$(OBJEXT) \ + gdbus/polkit.$(OBJEXT) +@TOOLS_TRUE@am_tools_snep_send_OBJECTS = $(am__objects_12) \ +@TOOLS_TRUE@ src/log.$(OBJEXT) src/dbus.$(OBJEXT) \ +@TOOLS_TRUE@ src/bluetooth.$(OBJEXT) src/ndef.$(OBJEXT) \ +@TOOLS_TRUE@ tools/snep-send.$(OBJEXT) src/error.$(OBJEXT) \ +@TOOLS_TRUE@ src/agent.$(OBJEXT) +tools_snep_send_OBJECTS = $(am_tools_snep_send_OBJECTS) +@TOOLS_TRUE@tools_snep_send_DEPENDENCIES = $(am__DEPENDENCIES_1) \ +@TOOLS_TRUE@ $(am__DEPENDENCIES_1) +am_unit_test_ndef_build_OBJECTS = $(am__objects_12) src/log.$(OBJEXT) \ + src/dbus.$(OBJEXT) src/error.$(OBJEXT) src/agent.$(OBJEXT) \ + src/bluetooth.$(OBJEXT) src/ndef.$(OBJEXT) \ + unit/test-ndef-build.$(OBJEXT) +unit_test_ndef_build_OBJECTS = $(am_unit_test_ndef_build_OBJECTS) +unit_test_ndef_build_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_unit_test_ndef_parse_OBJECTS = $(am__objects_12) src/log.$(OBJEXT) \ + src/dbus.$(OBJEXT) src/error.$(OBJEXT) src/agent.$(OBJEXT) \ + src/bluetooth.$(OBJEXT) src/ndef.$(OBJEXT) \ + unit/test-ndef-parse.$(OBJEXT) +unit_test_ndef_parse_OBJECTS = $(am_unit_test_ndef_parse_OBJECTS) +unit_test_ndef_parse_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_unit_test_snep_read_OBJECTS = $(am__objects_12) src/log.$(OBJEXT) \ + src/dbus.$(OBJEXT) src/error.$(OBJEXT) src/agent.$(OBJEXT) \ + src/bluetooth.$(OBJEXT) src/ndef.$(OBJEXT) src/snep.$(OBJEXT) \ + unit/test-snep-read.$(OBJEXT) unit/test-utils.$(OBJEXT) +unit_test_snep_read_OBJECTS = $(am_unit_test_snep_read_OBJECTS) +unit_test_snep_read_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +SCRIPTS = $(test_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +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) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(se_seeld_SOURCES) $(src_neard_SOURCES) \ + $(tools_nfctool_nfctool_SOURCES) $(tools_snep_send_SOURCES) \ + $(unit_test_ndef_build_SOURCES) \ + $(unit_test_ndef_parse_SOURCES) $(unit_test_snep_read_SOURCES) +DIST_SOURCES = $(am__se_seeld_SOURCES_DIST) \ + $(am__src_neard_SOURCES_DIST) \ + $(am__tools_nfctool_nfctool_SOURCES_DIST) \ + $(am__tools_snep_send_SOURCES_DIST) \ + $(unit_test_ndef_build_SOURCES) \ + $(unit_test_ndef_parse_SOURCES) $(unit_test_snep_read_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +man1dir = $(mandir)/man1 +man5dir = $(mandir)/man5 +man8dir = $(mandir)/man8 +NROFF = nroff +MANS = $(dist_man_MANS) +DATA = $(dist_dbus_DATA) $(dist_noinst_DATA) $(pkgconfig_DATA) \ + $(systemdsystemunit_DATA) +HEADERS = $(nodist_include_HEADERS) $(noinst_HEADERS) \ + $(pkginclude_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)config.h.in +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +CSCOPE = cscope +AM_RECURSIVE_TARGETS = cscope check recheck +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + if test -d "$(distdir)"; then \ + find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -rf "$(distdir)" \ + || { sleep 5 && rm -rf "$(distdir)"; }; \ + else :; fi +am__post_remove_distdir = $(am__remove_distdir) +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +DIST_TARGETS = dist-gzip +distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' +distcleancheck_listfiles = find . -type f -print +pkgincludedir = ${includedir}/near +pkglibexecdir = ${libexecdir}/nfc +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_DEPS = @DBUS_DEPS@ +DBUS_LIBS = @DBUS_LIBS@ +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@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_DEPS = @GLIB_DEPS@ +GLIB_LIBS = @GLIB_LIBS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBNL1_CFLAGS = @LIBNL1_CFLAGS@ +LIBNL1_LIBS = @LIBNL1_LIBS@ +LIBNL2_CFLAGS = @LIBNL2_CFLAGS@ +LIBNL2_LIBS = @LIBNL2_LIBS@ +LIBNL3_CFLAGS = @LIBNL3_CFLAGS@ +LIBNL3_LIBS = @LIBNL3_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NETLINK_CFLAGS = @NETLINK_CFLAGS@ +NETLINK_DEPS = @NETLINK_DEPS@ +NETLINK_LIBS = @NETLINK_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +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@ +STRIP = @STRIP@ +SYSTEMD_SYSTEMUNITDIR = @SYSTEMD_SYSTEMUNITDIR@ +SYSTEMD_USERUNITDIR = @SYSTEMD_USERUNITDIR@ +VERSION = @VERSION@ +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@ +plugindir = @plugindir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +se_plugindir = @se_plugindir@ +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 +AM_MAKEFLAGS = --no-print-directory +pkginclude_HEADERS = include/types.h include/log.h include/plugin.h \ + include/tag.h include/adapter.h include/ndef.h \ + include/tlv.h include/setting.h include/device.h \ + include/nfc_copy.h include/snep.h + +nodist_include_HEADERS = include/version.h +noinst_HEADERS = include/dbus.h +local_headers = $(foreach file,$(pkginclude_HEADERS) $(nodist_include_HEADERS) \ + $(noinst_HEADERS), include/near/$(notdir $(file))) + +gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/watch.c \ + gdbus/object.c gdbus/client.c gdbus/polkit.c + +plugin_LTLIBRARIES = +plugin_objects = +unit_objects = +builtin_modules = $(am__append_4) $(am__append_6) $(am__append_8) \ + $(am__append_10) $(am__append_12) $(am__append_14) +builtin_sources = $(am__append_5) $(am__append_7) $(am__append_9) \ + $(am__append_11) $(am__append_13) $(am__append_15) +builtin_cflags = +builtin_libadd = +src_neard_SOURCES = $(gdbus_sources) $(gweb_sources) $(builtin_sources) \ + src/main.c src/error.c src/near.h src/log.c \ + src/dbus.c src/manager.c src/adapter.c src/device.c \ + src/tag.c src/plugin.c src/netlink.c src/ndef.c \ + src/tlv.c src/bluetooth.c src/agent.c src/snep.c + +src_neard_LDADD = $(builtin_libadd) ${GLIB_LIBS} ${DBUS_LIBS} ${NETLINK_LIBS} -ldl +src_neard_LDFLAGS = -Wl,--export-dynamic +src_neard_DEPENDENCIES = src/neard.service +BUILT_SOURCES = src/builtin.h $(am__append_2) +AM_CPPFLAGS = ${GLIB_CFLAGS} ${DBUS_CFLAGS} ${NETLINK_CFLAGS} \ + -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""$(plugindir)"\" \ + -DCONFIGDIR=\""$(configdir)\"" \ + -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus + +AM_CFLAGS = ${builtin_cflags} -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus +@SE_TRUE@se_plugin_LTLIBRARIES = +@SE_TRUE@se_plugin_objects = +@SE_TRUE@builtin_se_modules = nfc +@SE_TRUE@builtin_se_sources = se/plugins/nfc.c +@SE_TRUE@builtin_se_libadd = @NETLINK_LIBS@ +@SE_TRUE@builtin_se_cflags = @NETLINK_CFLAGS@ +@SE_TRUE@se_seeld_SOURCES = $(gdbus_sources) $(builtin_se_sources) \ +@SE_TRUE@ src/log.c src/dbus.c src/error.c src/plugin.c \ +@SE_TRUE@ se/main.c se/seel.h se/manager.c se/manager.h \ +@SE_TRUE@ se/se.c se/driver.c se/driver.h se/apdu.c \ +@SE_TRUE@ se/channel.c se/ace.c + +@SE_TRUE@se_seeld_LDADD = $(builtin_se_libadd) @GLIB_LIBS@ @DBUS_LIBS@ -ldl +@SE_TRUE@se_seeld_LDFLAGS = -Wl,--export-dynamic +src_neard_CFLAGS = ${builtin_cflags} -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus +src_neard_CPPFLAGS = ${GLIB_CFLAGS} ${DBUS_CFLAGS} ${NETLINK_CFLAGS} \ + -DNEAR_PLUGIN_BUILTIN \ + -DPLUGINDIR=\""$(plugindir)"\" \ + -DCONFIGDIR=\""$(configdir)\"" \ + -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus + +@SE_TRUE@src_seeld_CFLAGS = ${builtin_se_cflags} -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus +@SE_TRUE@se_seeld_CPPFLAGS = ${GLIB_CFLAGS} ${DBUS_CFLAGS} ${NETLINK_CFLAGS} \ +@SE_TRUE@ -DNEAR_PLUGIN_BUILTIN \ +@SE_TRUE@ -DPLUGINDIR=\""$(build_se_plugindir)"\" \ +@SE_TRUE@ -DCONFIGDIR=\""$(configdir)\"" \ +@SE_TRUE@ -I$(builddir)/se + +CLEANFILES = src/builtin.h se/builtin.h $(local_headers) \ + src/neard.service +configdir = ${sysconfdir}/neard +dist_noinst_DATA = src/main.conf +dbusdir = ${sysconfdir}/dbus-1/system.d/ +dist_dbus_DATA = src/org.neard.conf +@MAINTAINER_MODE_FALSE@@SE_TRUE@build_se_plugindir = $(se_plugindir) +@MAINTAINER_MODE_TRUE@@SE_TRUE@build_se_plugindir = $(abs_top_srcdir)/se/plugins/.libs +@MAINTAINER_MODE_FALSE@build_plugindir = $(plugindir) +@MAINTAINER_MODE_TRUE@build_plugindir = $(abs_top_srcdir)/plugins/.libs +doc_files = doc/tag-api.txt doc/device-api.txt doc/adapter-api.txt \ + doc/agent-api.txt doc/phdc-api.txt \ + doc/secureelement-api.txt doc/se-manager-api.txt + +EXTRA_DIST = src/genbuiltin $(doc_files) src/neard.service.in \ + $(test_scripts) +dist_man_MANS = doc/neard.8 doc/neard.conf.5 doc/nfctool.1 +test_scripts = test/test-adapter test/test-device \ + test/test-tag test/monitor-near test/bt-handover \ + test/handover-agent test/phdc-simple-manager \ + test/neardutils.py + +@SYSTEMD_TRUE@systemdsystemunitdir = ${SYSTEMD_SYSTEMUNITDIR} +@SYSTEMD_TRUE@systemdsystemunit_DATA = src/neard.service +@TEST_TRUE@testdir = $(pkglibdir)/test +@TEST_TRUE@test_SCRIPTS = $(test_scripts) +@TOOLS_TRUE@tools_snep_send_SOURCES = $(gdbus_sources) src/log.c src/dbus.c \ +@TOOLS_TRUE@ src/bluetooth.c src/ndef.c \ +@TOOLS_TRUE@ tools/snep-send.c src/error.c \ +@TOOLS_TRUE@ src/agent.c + +@TOOLS_TRUE@tools_snep_send_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} +@TOOLS_TRUE@tools_nfctool_nfctool_SOURCES = $(gdbus_sources) tools/nfctool/main.c \ +@TOOLS_TRUE@ tools/nfctool/nfctool.h \ +@TOOLS_TRUE@ tools/nfctool/adapter.h \ +@TOOLS_TRUE@ tools/nfctool/adapter.c \ +@TOOLS_TRUE@ tools/nfctool/netlink.h \ +@TOOLS_TRUE@ tools/nfctool/netlink.c \ +@TOOLS_TRUE@ tools/nfctool/sniffer.h \ +@TOOLS_TRUE@ tools/nfctool/sniffer.c \ +@TOOLS_TRUE@ tools/nfctool/llcp-decode.h \ +@TOOLS_TRUE@ tools/nfctool/llcp-decode.c \ +@TOOLS_TRUE@ tools/nfctool/snep-decode.h \ +@TOOLS_TRUE@ tools/nfctool/snep-decode.c \ +@TOOLS_TRUE@ tools/nfctool/ndef-decode.h \ +@TOOLS_TRUE@ tools/nfctool/ndef-decode.c \ +@TOOLS_TRUE@ tools/nfctool/display.h \ +@TOOLS_TRUE@ tools/nfctool/display.c \ +@TOOLS_TRUE@ src/log.c src/dbus.c \ +@TOOLS_TRUE@ src/bluetooth.c src/ndef.c \ +@TOOLS_TRUE@ src/error.c src/agent.c + +@TOOLS_TRUE@tools_nfctool_nfctool_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} ${NETLINK_LIBS} +tools_nfctool_nfctool_CPPFLAGS = ${GLIB_CFLAGS} ${DBUS_CFLAGS} ${NETLINK_CFLAGS} \ + -DNEAR_PLUGIN_BUILTIN \ + -DPLUGINDIR=\""$(plugindir)"\" \ + -DCONFIGDIR=\""$(configdir)\"" \ + -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus + +unit_tests = unit/test-ndef-parse unit/test-ndef-build unit/test-snep-read +unit_test_ndef_parse_SOURCES = $(gdbus_sources) src/log.c src/dbus.c \ + src/error.c src/agent.c \ + src/bluetooth.c src/ndef.c \ + unit/test-ndef-parse.c + +unit_test_ndef_parse_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} +unit_test_ndef_build_SOURCES = $(gdbus_sources) src/log.c src/dbus.c \ + src/error.c src/agent.c \ + src/bluetooth.c src/ndef.c \ + unit/test-ndef-build.c + +unit_test_ndef_build_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} +unit_test_snep_read_SOURCES = $(gdbus_sources) src/log.c src/dbus.c \ + src/error.c src/agent.c \ + src/bluetooth.c src/ndef.c src/snep.c \ + unit/test-snep-read.c unit/test-utils.c \ + unit/test-utils.h + +unit_test_snep_read_LDADD = ${GLIB_LIBS} ${DBUS_LIBS} +plugin_cflags = -fvisibility=hidden -I$(srcdir)/gdbus \ + @DBUS_CFLAGS@ @GLIB_CFLAGS@ + +plugin_ldflags = -no-undefined -module -avoid-version +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = neard.pc +DISTCHECK_CONFIGURE_FLAGS = --enable-tools --enable-ese --disable-systemd +DISTCLEANFILES = $(pkgconfig_DATA) +MAINTAINERCLEANFILES = Makefile.in \ + aclocal.m4 configure config.h.in config.sub config.guess \ + ltmain.sh depcomp compile missing install-sh mkinstalldirs + +SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \ + $(SED) -e 's,@pkglibexecdir\@,$(pkglibexecdir),g' \ + < $< > $@ + +all: $(BUILT_SOURCES) config.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/Makefile.plugins $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign 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; +$(srcdir)/Makefile.plugins: + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 + +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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +include/version.h: $(top_builddir)/config.status $(top_srcdir)/include/version.h.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +neard.pc: $(top_builddir)/config.status $(srcdir)/neard.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $@ + +install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(plugindir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \ + } + +uninstall-pluginLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \ + done + +clean-pluginLTLIBRARIES: + -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES) + @list='$(plugin_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +install-se_pluginLTLIBRARIES: $(se_plugin_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(se_plugin_LTLIBRARIES)'; test -n "$(se_plugindir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(se_plugindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(se_plugindir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(se_plugindir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(se_plugindir)"; \ + } + +uninstall-se_pluginLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(se_plugin_LTLIBRARIES)'; test -n "$(se_plugindir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(se_plugindir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(se_plugindir)/$$f"; \ + done + +clean-se_pluginLTLIBRARIES: + -test -z "$(se_plugin_LTLIBRARIES)" || rm -f $(se_plugin_LTLIBRARIES) + @list='$(se_plugin_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + 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)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || 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)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_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 + +clean-checkPROGRAMS: + @list='$(check_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 + +clean-noinstPROGRAMS: + @list='$(noinst_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 +install-pkglibexecPROGRAMS: $(pkglibexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(pkglibexec_PROGRAMS)'; test -n "$(pkglibexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkglibexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkglibexecdir)" || exit 1; \ + fi; \ + 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)$(pkglibexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(pkglibexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-pkglibexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(pkglibexec_PROGRAMS)'; test -n "$(pkglibexecdir)" || 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)$(pkglibexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(pkglibexecdir)" && rm -f $$files + +clean-pkglibexecPROGRAMS: + @list='$(pkglibexec_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 +gdbus/$(am__dirstamp): + @$(MKDIR_P) gdbus + @: > gdbus/$(am__dirstamp) +gdbus/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) gdbus/$(DEPDIR) + @: > gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/se_seeld-mainloop.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/se_seeld-watch.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/se_seeld-object.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/se_seeld-client.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/se_seeld-polkit.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +se/plugins/$(am__dirstamp): + @$(MKDIR_P) se/plugins + @: > se/plugins/$(am__dirstamp) +se/plugins/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) se/plugins/$(DEPDIR) + @: > se/plugins/$(DEPDIR)/$(am__dirstamp) +se/plugins/se_seeld-nfc.$(OBJEXT): se/plugins/$(am__dirstamp) \ + se/plugins/$(DEPDIR)/$(am__dirstamp) +src/$(am__dirstamp): + @$(MKDIR_P) src + @: > src/$(am__dirstamp) +src/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) src/$(DEPDIR) + @: > src/$(DEPDIR)/$(am__dirstamp) +src/se_seeld-log.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/se_seeld-dbus.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/se_seeld-error.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/se_seeld-plugin.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +se/$(am__dirstamp): + @$(MKDIR_P) se + @: > se/$(am__dirstamp) +se/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) se/$(DEPDIR) + @: > se/$(DEPDIR)/$(am__dirstamp) +se/se_seeld-main.$(OBJEXT): se/$(am__dirstamp) \ + se/$(DEPDIR)/$(am__dirstamp) +se/se_seeld-manager.$(OBJEXT): se/$(am__dirstamp) \ + se/$(DEPDIR)/$(am__dirstamp) +se/se_seeld-se.$(OBJEXT): se/$(am__dirstamp) \ + se/$(DEPDIR)/$(am__dirstamp) +se/se_seeld-driver.$(OBJEXT): se/$(am__dirstamp) \ + se/$(DEPDIR)/$(am__dirstamp) +se/se_seeld-apdu.$(OBJEXT): se/$(am__dirstamp) \ + se/$(DEPDIR)/$(am__dirstamp) +se/se_seeld-channel.$(OBJEXT): se/$(am__dirstamp) \ + se/$(DEPDIR)/$(am__dirstamp) +se/se_seeld-ace.$(OBJEXT): se/$(am__dirstamp) \ + se/$(DEPDIR)/$(am__dirstamp) + +se/seeld$(EXEEXT): $(se_seeld_OBJECTS) $(se_seeld_DEPENDENCIES) $(EXTRA_se_seeld_DEPENDENCIES) se/$(am__dirstamp) + @rm -f se/seeld$(EXEEXT) + $(AM_V_CCLD)$(se_seeld_LINK) $(se_seeld_OBJECTS) $(se_seeld_LDADD) $(LIBS) +gdbus/src_neard-mainloop.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/src_neard-watch.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/src_neard-object.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/src_neard-client.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/src_neard-polkit.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +plugins/$(am__dirstamp): + @$(MKDIR_P) plugins + @: > plugins/$(am__dirstamp) +plugins/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) plugins/$(DEPDIR) + @: > plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-nfctype1.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-nfctype2.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-mifare.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-nfctype3.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-nfctype4.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-nfctype5.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-p2p.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-npp.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-snep.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-snep-validation.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-llcp-validation.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-handover.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +plugins/src_neard-phdc.$(OBJEXT): plugins/$(am__dirstamp) \ + plugins/$(DEPDIR)/$(am__dirstamp) +src/src_neard-main.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-error.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-log.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-dbus.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-manager.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-adapter.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-device.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-tag.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-plugin.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-netlink.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-ndef.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-tlv.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-bluetooth.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-agent.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/src_neard-snep.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) + +src/neard$(EXEEXT): $(src_neard_OBJECTS) $(src_neard_DEPENDENCIES) $(EXTRA_src_neard_DEPENDENCIES) src/$(am__dirstamp) + @rm -f src/neard$(EXEEXT) + $(AM_V_CCLD)$(src_neard_LINK) $(src_neard_OBJECTS) $(src_neard_LDADD) $(LIBS) +gdbus/tools_nfctool_nfctool-mainloop.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/tools_nfctool_nfctool-watch.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/tools_nfctool_nfctool-object.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/tools_nfctool_nfctool-client.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/tools_nfctool_nfctool-polkit.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +tools/nfctool/$(am__dirstamp): + @$(MKDIR_P) tools/nfctool + @: > tools/nfctool/$(am__dirstamp) +tools/nfctool/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tools/nfctool/$(DEPDIR) + @: > tools/nfctool/$(DEPDIR)/$(am__dirstamp) +tools/nfctool/tools_nfctool_nfctool-main.$(OBJEXT): \ + tools/nfctool/$(am__dirstamp) \ + tools/nfctool/$(DEPDIR)/$(am__dirstamp) +tools/nfctool/tools_nfctool_nfctool-adapter.$(OBJEXT): \ + tools/nfctool/$(am__dirstamp) \ + tools/nfctool/$(DEPDIR)/$(am__dirstamp) +tools/nfctool/tools_nfctool_nfctool-netlink.$(OBJEXT): \ + tools/nfctool/$(am__dirstamp) \ + tools/nfctool/$(DEPDIR)/$(am__dirstamp) +tools/nfctool/tools_nfctool_nfctool-sniffer.$(OBJEXT): \ + tools/nfctool/$(am__dirstamp) \ + tools/nfctool/$(DEPDIR)/$(am__dirstamp) +tools/nfctool/tools_nfctool_nfctool-llcp-decode.$(OBJEXT): \ + tools/nfctool/$(am__dirstamp) \ + tools/nfctool/$(DEPDIR)/$(am__dirstamp) +tools/nfctool/tools_nfctool_nfctool-snep-decode.$(OBJEXT): \ + tools/nfctool/$(am__dirstamp) \ + tools/nfctool/$(DEPDIR)/$(am__dirstamp) +tools/nfctool/tools_nfctool_nfctool-ndef-decode.$(OBJEXT): \ + tools/nfctool/$(am__dirstamp) \ + tools/nfctool/$(DEPDIR)/$(am__dirstamp) +tools/nfctool/tools_nfctool_nfctool-display.$(OBJEXT): \ + tools/nfctool/$(am__dirstamp) \ + tools/nfctool/$(DEPDIR)/$(am__dirstamp) +src/tools_nfctool_nfctool-log.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/tools_nfctool_nfctool-dbus.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/tools_nfctool_nfctool-bluetooth.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/tools_nfctool_nfctool-ndef.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/tools_nfctool_nfctool-error.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/tools_nfctool_nfctool-agent.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) + +tools/nfctool/nfctool$(EXEEXT): $(tools_nfctool_nfctool_OBJECTS) $(tools_nfctool_nfctool_DEPENDENCIES) $(EXTRA_tools_nfctool_nfctool_DEPENDENCIES) tools/nfctool/$(am__dirstamp) + @rm -f tools/nfctool/nfctool$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tools_nfctool_nfctool_OBJECTS) $(tools_nfctool_nfctool_LDADD) $(LIBS) +gdbus/mainloop.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/watch.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/object.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/client.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +gdbus/polkit.$(OBJEXT): gdbus/$(am__dirstamp) \ + gdbus/$(DEPDIR)/$(am__dirstamp) +src/log.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/dbus.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/bluetooth.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/ndef.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +tools/$(am__dirstamp): + @$(MKDIR_P) tools + @: > tools/$(am__dirstamp) +tools/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tools/$(DEPDIR) + @: > tools/$(DEPDIR)/$(am__dirstamp) +tools/snep-send.$(OBJEXT): tools/$(am__dirstamp) \ + tools/$(DEPDIR)/$(am__dirstamp) +src/error.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/agent.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) + +tools/snep-send$(EXEEXT): $(tools_snep_send_OBJECTS) $(tools_snep_send_DEPENDENCIES) $(EXTRA_tools_snep_send_DEPENDENCIES) tools/$(am__dirstamp) + @rm -f tools/snep-send$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tools_snep_send_OBJECTS) $(tools_snep_send_LDADD) $(LIBS) +unit/$(am__dirstamp): + @$(MKDIR_P) unit + @: > unit/$(am__dirstamp) +unit/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) unit/$(DEPDIR) + @: > unit/$(DEPDIR)/$(am__dirstamp) +unit/test-ndef-build.$(OBJEXT): unit/$(am__dirstamp) \ + unit/$(DEPDIR)/$(am__dirstamp) + +unit/test-ndef-build$(EXEEXT): $(unit_test_ndef_build_OBJECTS) $(unit_test_ndef_build_DEPENDENCIES) $(EXTRA_unit_test_ndef_build_DEPENDENCIES) unit/$(am__dirstamp) + @rm -f unit/test-ndef-build$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(unit_test_ndef_build_OBJECTS) $(unit_test_ndef_build_LDADD) $(LIBS) +unit/test-ndef-parse.$(OBJEXT): unit/$(am__dirstamp) \ + unit/$(DEPDIR)/$(am__dirstamp) + +unit/test-ndef-parse$(EXEEXT): $(unit_test_ndef_parse_OBJECTS) $(unit_test_ndef_parse_DEPENDENCIES) $(EXTRA_unit_test_ndef_parse_DEPENDENCIES) unit/$(am__dirstamp) + @rm -f unit/test-ndef-parse$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(unit_test_ndef_parse_OBJECTS) $(unit_test_ndef_parse_LDADD) $(LIBS) +src/snep.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +unit/test-snep-read.$(OBJEXT): unit/$(am__dirstamp) \ + unit/$(DEPDIR)/$(am__dirstamp) +unit/test-utils.$(OBJEXT): unit/$(am__dirstamp) \ + unit/$(DEPDIR)/$(am__dirstamp) + +unit/test-snep-read$(EXEEXT): $(unit_test_snep_read_OBJECTS) $(unit_test_snep_read_DEPENDENCIES) $(EXTRA_unit_test_snep_read_DEPENDENCIES) unit/$(am__dirstamp) + @rm -f unit/test-snep-read$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(unit_test_snep_read_OBJECTS) $(unit_test_snep_read_LDADD) $(LIBS) +install-testSCRIPTS: $(test_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(test_SCRIPTS)'; test -n "$(testdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(testdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(testdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | 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; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$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_SCRIPT) $$files '$(DESTDIR)$(testdir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(testdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-testSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(test_SCRIPTS)'; test -n "$(testdir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(testdir)'; $(am__uninstall_files_from_dir) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f gdbus/*.$(OBJEXT) + -rm -f plugins/*.$(OBJEXT) + -rm -f se/*.$(OBJEXT) + -rm -f se/plugins/*.$(OBJEXT) + -rm -f src/*.$(OBJEXT) + -rm -f tools/*.$(OBJEXT) + -rm -f tools/nfctool/*.$(OBJEXT) + -rm -f unit/*.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/client.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/mainloop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/object.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/polkit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/se_seeld-client.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/se_seeld-mainloop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/se_seeld-object.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/se_seeld-polkit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/se_seeld-watch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/src_neard-client.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/src_neard-mainloop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/src_neard-object.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/src_neard-polkit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/src_neard-watch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/tools_nfctool_nfctool-client.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/tools_nfctool_nfctool-mainloop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/tools_nfctool_nfctool-object.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/tools_nfctool_nfctool-polkit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/tools_nfctool_nfctool-watch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gdbus/$(DEPDIR)/watch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-handover.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-llcp-validation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-mifare.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-nfctype1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-nfctype2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-nfctype3.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-nfctype4.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-nfctype5.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-npp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-p2p.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-phdc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-snep-validation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/src_neard-snep.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@se/$(DEPDIR)/se_seeld-ace.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@se/$(DEPDIR)/se_seeld-apdu.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@se/$(DEPDIR)/se_seeld-channel.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@se/$(DEPDIR)/se_seeld-driver.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@se/$(DEPDIR)/se_seeld-main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@se/$(DEPDIR)/se_seeld-manager.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@se/$(DEPDIR)/se_seeld-se.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@se/plugins/$(DEPDIR)/se_seeld-nfc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/agent.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/bluetooth.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dbus.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/error.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/log.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/ndef.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/se_seeld-dbus.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/se_seeld-error.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/se_seeld-log.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/se_seeld-plugin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/snep.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-adapter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-agent.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-bluetooth.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-dbus.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-device.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-error.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-log.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-manager.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-ndef.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-netlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-plugin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-snep.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-tag.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/src_neard-tlv.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/tools_nfctool_nfctool-agent.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/tools_nfctool_nfctool-bluetooth.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/tools_nfctool_nfctool-dbus.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/tools_nfctool_nfctool-error.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/tools_nfctool_nfctool-log.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/tools_nfctool_nfctool-ndef.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/snep-send.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-adapter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-display.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-llcp-decode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-ndef-decode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-netlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-snep-decode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-sniffer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@unit/$(DEPDIR)/test-ndef-build.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@unit/$(DEPDIR)/test-ndef-parse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@unit/$(DEPDIR)/test-snep-read.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@unit/$(DEPDIR)/test-utils.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +gdbus/se_seeld-mainloop.o: gdbus/mainloop.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-mainloop.o -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-mainloop.Tpo -c -o gdbus/se_seeld-mainloop.o `test -f 'gdbus/mainloop.c' || echo '$(srcdir)/'`gdbus/mainloop.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-mainloop.Tpo gdbus/$(DEPDIR)/se_seeld-mainloop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/mainloop.c' object='gdbus/se_seeld-mainloop.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-mainloop.o `test -f 'gdbus/mainloop.c' || echo '$(srcdir)/'`gdbus/mainloop.c + +gdbus/se_seeld-mainloop.obj: gdbus/mainloop.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-mainloop.obj -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-mainloop.Tpo -c -o gdbus/se_seeld-mainloop.obj `if test -f 'gdbus/mainloop.c'; then $(CYGPATH_W) 'gdbus/mainloop.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/mainloop.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-mainloop.Tpo gdbus/$(DEPDIR)/se_seeld-mainloop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/mainloop.c' object='gdbus/se_seeld-mainloop.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-mainloop.obj `if test -f 'gdbus/mainloop.c'; then $(CYGPATH_W) 'gdbus/mainloop.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/mainloop.c'; fi` + +gdbus/se_seeld-watch.o: gdbus/watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-watch.o -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-watch.Tpo -c -o gdbus/se_seeld-watch.o `test -f 'gdbus/watch.c' || echo '$(srcdir)/'`gdbus/watch.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-watch.Tpo gdbus/$(DEPDIR)/se_seeld-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/watch.c' object='gdbus/se_seeld-watch.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-watch.o `test -f 'gdbus/watch.c' || echo '$(srcdir)/'`gdbus/watch.c + +gdbus/se_seeld-watch.obj: gdbus/watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-watch.obj -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-watch.Tpo -c -o gdbus/se_seeld-watch.obj `if test -f 'gdbus/watch.c'; then $(CYGPATH_W) 'gdbus/watch.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/watch.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-watch.Tpo gdbus/$(DEPDIR)/se_seeld-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/watch.c' object='gdbus/se_seeld-watch.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-watch.obj `if test -f 'gdbus/watch.c'; then $(CYGPATH_W) 'gdbus/watch.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/watch.c'; fi` + +gdbus/se_seeld-object.o: gdbus/object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-object.o -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-object.Tpo -c -o gdbus/se_seeld-object.o `test -f 'gdbus/object.c' || echo '$(srcdir)/'`gdbus/object.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-object.Tpo gdbus/$(DEPDIR)/se_seeld-object.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/object.c' object='gdbus/se_seeld-object.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-object.o `test -f 'gdbus/object.c' || echo '$(srcdir)/'`gdbus/object.c + +gdbus/se_seeld-object.obj: gdbus/object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-object.obj -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-object.Tpo -c -o gdbus/se_seeld-object.obj `if test -f 'gdbus/object.c'; then $(CYGPATH_W) 'gdbus/object.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/object.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-object.Tpo gdbus/$(DEPDIR)/se_seeld-object.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/object.c' object='gdbus/se_seeld-object.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-object.obj `if test -f 'gdbus/object.c'; then $(CYGPATH_W) 'gdbus/object.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/object.c'; fi` + +gdbus/se_seeld-client.o: gdbus/client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-client.o -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-client.Tpo -c -o gdbus/se_seeld-client.o `test -f 'gdbus/client.c' || echo '$(srcdir)/'`gdbus/client.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-client.Tpo gdbus/$(DEPDIR)/se_seeld-client.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/client.c' object='gdbus/se_seeld-client.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-client.o `test -f 'gdbus/client.c' || echo '$(srcdir)/'`gdbus/client.c + +gdbus/se_seeld-client.obj: gdbus/client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-client.obj -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-client.Tpo -c -o gdbus/se_seeld-client.obj `if test -f 'gdbus/client.c'; then $(CYGPATH_W) 'gdbus/client.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/client.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-client.Tpo gdbus/$(DEPDIR)/se_seeld-client.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/client.c' object='gdbus/se_seeld-client.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-client.obj `if test -f 'gdbus/client.c'; then $(CYGPATH_W) 'gdbus/client.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/client.c'; fi` + +gdbus/se_seeld-polkit.o: gdbus/polkit.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-polkit.o -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-polkit.Tpo -c -o gdbus/se_seeld-polkit.o `test -f 'gdbus/polkit.c' || echo '$(srcdir)/'`gdbus/polkit.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-polkit.Tpo gdbus/$(DEPDIR)/se_seeld-polkit.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/polkit.c' object='gdbus/se_seeld-polkit.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-polkit.o `test -f 'gdbus/polkit.c' || echo '$(srcdir)/'`gdbus/polkit.c + +gdbus/se_seeld-polkit.obj: gdbus/polkit.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/se_seeld-polkit.obj -MD -MP -MF gdbus/$(DEPDIR)/se_seeld-polkit.Tpo -c -o gdbus/se_seeld-polkit.obj `if test -f 'gdbus/polkit.c'; then $(CYGPATH_W) 'gdbus/polkit.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/polkit.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/se_seeld-polkit.Tpo gdbus/$(DEPDIR)/se_seeld-polkit.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/polkit.c' object='gdbus/se_seeld-polkit.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/se_seeld-polkit.obj `if test -f 'gdbus/polkit.c'; then $(CYGPATH_W) 'gdbus/polkit.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/polkit.c'; fi` + +se/plugins/se_seeld-nfc.o: se/plugins/nfc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/plugins/se_seeld-nfc.o -MD -MP -MF se/plugins/$(DEPDIR)/se_seeld-nfc.Tpo -c -o se/plugins/se_seeld-nfc.o `test -f 'se/plugins/nfc.c' || echo '$(srcdir)/'`se/plugins/nfc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/plugins/$(DEPDIR)/se_seeld-nfc.Tpo se/plugins/$(DEPDIR)/se_seeld-nfc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/plugins/nfc.c' object='se/plugins/se_seeld-nfc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/plugins/se_seeld-nfc.o `test -f 'se/plugins/nfc.c' || echo '$(srcdir)/'`se/plugins/nfc.c + +se/plugins/se_seeld-nfc.obj: se/plugins/nfc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/plugins/se_seeld-nfc.obj -MD -MP -MF se/plugins/$(DEPDIR)/se_seeld-nfc.Tpo -c -o se/plugins/se_seeld-nfc.obj `if test -f 'se/plugins/nfc.c'; then $(CYGPATH_W) 'se/plugins/nfc.c'; else $(CYGPATH_W) '$(srcdir)/se/plugins/nfc.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/plugins/$(DEPDIR)/se_seeld-nfc.Tpo se/plugins/$(DEPDIR)/se_seeld-nfc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/plugins/nfc.c' object='se/plugins/se_seeld-nfc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/plugins/se_seeld-nfc.obj `if test -f 'se/plugins/nfc.c'; then $(CYGPATH_W) 'se/plugins/nfc.c'; else $(CYGPATH_W) '$(srcdir)/se/plugins/nfc.c'; fi` + +src/se_seeld-log.o: src/log.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/se_seeld-log.o -MD -MP -MF src/$(DEPDIR)/se_seeld-log.Tpo -c -o src/se_seeld-log.o `test -f 'src/log.c' || echo '$(srcdir)/'`src/log.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/se_seeld-log.Tpo src/$(DEPDIR)/se_seeld-log.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/log.c' object='src/se_seeld-log.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/se_seeld-log.o `test -f 'src/log.c' || echo '$(srcdir)/'`src/log.c + +src/se_seeld-log.obj: src/log.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/se_seeld-log.obj -MD -MP -MF src/$(DEPDIR)/se_seeld-log.Tpo -c -o src/se_seeld-log.obj `if test -f 'src/log.c'; then $(CYGPATH_W) 'src/log.c'; else $(CYGPATH_W) '$(srcdir)/src/log.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/se_seeld-log.Tpo src/$(DEPDIR)/se_seeld-log.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/log.c' object='src/se_seeld-log.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/se_seeld-log.obj `if test -f 'src/log.c'; then $(CYGPATH_W) 'src/log.c'; else $(CYGPATH_W) '$(srcdir)/src/log.c'; fi` + +src/se_seeld-dbus.o: src/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/se_seeld-dbus.o -MD -MP -MF src/$(DEPDIR)/se_seeld-dbus.Tpo -c -o src/se_seeld-dbus.o `test -f 'src/dbus.c' || echo '$(srcdir)/'`src/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/se_seeld-dbus.Tpo src/$(DEPDIR)/se_seeld-dbus.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/dbus.c' object='src/se_seeld-dbus.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/se_seeld-dbus.o `test -f 'src/dbus.c' || echo '$(srcdir)/'`src/dbus.c + +src/se_seeld-dbus.obj: src/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/se_seeld-dbus.obj -MD -MP -MF src/$(DEPDIR)/se_seeld-dbus.Tpo -c -o src/se_seeld-dbus.obj `if test -f 'src/dbus.c'; then $(CYGPATH_W) 'src/dbus.c'; else $(CYGPATH_W) '$(srcdir)/src/dbus.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/se_seeld-dbus.Tpo src/$(DEPDIR)/se_seeld-dbus.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/dbus.c' object='src/se_seeld-dbus.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/se_seeld-dbus.obj `if test -f 'src/dbus.c'; then $(CYGPATH_W) 'src/dbus.c'; else $(CYGPATH_W) '$(srcdir)/src/dbus.c'; fi` + +src/se_seeld-error.o: src/error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/se_seeld-error.o -MD -MP -MF src/$(DEPDIR)/se_seeld-error.Tpo -c -o src/se_seeld-error.o `test -f 'src/error.c' || echo '$(srcdir)/'`src/error.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/se_seeld-error.Tpo src/$(DEPDIR)/se_seeld-error.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/error.c' object='src/se_seeld-error.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/se_seeld-error.o `test -f 'src/error.c' || echo '$(srcdir)/'`src/error.c + +src/se_seeld-error.obj: src/error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/se_seeld-error.obj -MD -MP -MF src/$(DEPDIR)/se_seeld-error.Tpo -c -o src/se_seeld-error.obj `if test -f 'src/error.c'; then $(CYGPATH_W) 'src/error.c'; else $(CYGPATH_W) '$(srcdir)/src/error.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/se_seeld-error.Tpo src/$(DEPDIR)/se_seeld-error.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/error.c' object='src/se_seeld-error.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/se_seeld-error.obj `if test -f 'src/error.c'; then $(CYGPATH_W) 'src/error.c'; else $(CYGPATH_W) '$(srcdir)/src/error.c'; fi` + +src/se_seeld-plugin.o: src/plugin.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/se_seeld-plugin.o -MD -MP -MF src/$(DEPDIR)/se_seeld-plugin.Tpo -c -o src/se_seeld-plugin.o `test -f 'src/plugin.c' || echo '$(srcdir)/'`src/plugin.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/se_seeld-plugin.Tpo src/$(DEPDIR)/se_seeld-plugin.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/plugin.c' object='src/se_seeld-plugin.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/se_seeld-plugin.o `test -f 'src/plugin.c' || echo '$(srcdir)/'`src/plugin.c + +src/se_seeld-plugin.obj: src/plugin.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/se_seeld-plugin.obj -MD -MP -MF src/$(DEPDIR)/se_seeld-plugin.Tpo -c -o src/se_seeld-plugin.obj `if test -f 'src/plugin.c'; then $(CYGPATH_W) 'src/plugin.c'; else $(CYGPATH_W) '$(srcdir)/src/plugin.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/se_seeld-plugin.Tpo src/$(DEPDIR)/se_seeld-plugin.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/plugin.c' object='src/se_seeld-plugin.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/se_seeld-plugin.obj `if test -f 'src/plugin.c'; then $(CYGPATH_W) 'src/plugin.c'; else $(CYGPATH_W) '$(srcdir)/src/plugin.c'; fi` + +se/se_seeld-main.o: se/main.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-main.o -MD -MP -MF se/$(DEPDIR)/se_seeld-main.Tpo -c -o se/se_seeld-main.o `test -f 'se/main.c' || echo '$(srcdir)/'`se/main.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-main.Tpo se/$(DEPDIR)/se_seeld-main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/main.c' object='se/se_seeld-main.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-main.o `test -f 'se/main.c' || echo '$(srcdir)/'`se/main.c + +se/se_seeld-main.obj: se/main.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-main.obj -MD -MP -MF se/$(DEPDIR)/se_seeld-main.Tpo -c -o se/se_seeld-main.obj `if test -f 'se/main.c'; then $(CYGPATH_W) 'se/main.c'; else $(CYGPATH_W) '$(srcdir)/se/main.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-main.Tpo se/$(DEPDIR)/se_seeld-main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/main.c' object='se/se_seeld-main.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-main.obj `if test -f 'se/main.c'; then $(CYGPATH_W) 'se/main.c'; else $(CYGPATH_W) '$(srcdir)/se/main.c'; fi` + +se/se_seeld-manager.o: se/manager.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-manager.o -MD -MP -MF se/$(DEPDIR)/se_seeld-manager.Tpo -c -o se/se_seeld-manager.o `test -f 'se/manager.c' || echo '$(srcdir)/'`se/manager.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-manager.Tpo se/$(DEPDIR)/se_seeld-manager.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/manager.c' object='se/se_seeld-manager.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-manager.o `test -f 'se/manager.c' || echo '$(srcdir)/'`se/manager.c + +se/se_seeld-manager.obj: se/manager.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-manager.obj -MD -MP -MF se/$(DEPDIR)/se_seeld-manager.Tpo -c -o se/se_seeld-manager.obj `if test -f 'se/manager.c'; then $(CYGPATH_W) 'se/manager.c'; else $(CYGPATH_W) '$(srcdir)/se/manager.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-manager.Tpo se/$(DEPDIR)/se_seeld-manager.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/manager.c' object='se/se_seeld-manager.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-manager.obj `if test -f 'se/manager.c'; then $(CYGPATH_W) 'se/manager.c'; else $(CYGPATH_W) '$(srcdir)/se/manager.c'; fi` + +se/se_seeld-se.o: se/se.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-se.o -MD -MP -MF se/$(DEPDIR)/se_seeld-se.Tpo -c -o se/se_seeld-se.o `test -f 'se/se.c' || echo '$(srcdir)/'`se/se.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-se.Tpo se/$(DEPDIR)/se_seeld-se.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/se.c' object='se/se_seeld-se.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-se.o `test -f 'se/se.c' || echo '$(srcdir)/'`se/se.c + +se/se_seeld-se.obj: se/se.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-se.obj -MD -MP -MF se/$(DEPDIR)/se_seeld-se.Tpo -c -o se/se_seeld-se.obj `if test -f 'se/se.c'; then $(CYGPATH_W) 'se/se.c'; else $(CYGPATH_W) '$(srcdir)/se/se.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-se.Tpo se/$(DEPDIR)/se_seeld-se.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/se.c' object='se/se_seeld-se.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-se.obj `if test -f 'se/se.c'; then $(CYGPATH_W) 'se/se.c'; else $(CYGPATH_W) '$(srcdir)/se/se.c'; fi` + +se/se_seeld-driver.o: se/driver.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-driver.o -MD -MP -MF se/$(DEPDIR)/se_seeld-driver.Tpo -c -o se/se_seeld-driver.o `test -f 'se/driver.c' || echo '$(srcdir)/'`se/driver.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-driver.Tpo se/$(DEPDIR)/se_seeld-driver.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/driver.c' object='se/se_seeld-driver.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-driver.o `test -f 'se/driver.c' || echo '$(srcdir)/'`se/driver.c + +se/se_seeld-driver.obj: se/driver.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-driver.obj -MD -MP -MF se/$(DEPDIR)/se_seeld-driver.Tpo -c -o se/se_seeld-driver.obj `if test -f 'se/driver.c'; then $(CYGPATH_W) 'se/driver.c'; else $(CYGPATH_W) '$(srcdir)/se/driver.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-driver.Tpo se/$(DEPDIR)/se_seeld-driver.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/driver.c' object='se/se_seeld-driver.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-driver.obj `if test -f 'se/driver.c'; then $(CYGPATH_W) 'se/driver.c'; else $(CYGPATH_W) '$(srcdir)/se/driver.c'; fi` + +se/se_seeld-apdu.o: se/apdu.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-apdu.o -MD -MP -MF se/$(DEPDIR)/se_seeld-apdu.Tpo -c -o se/se_seeld-apdu.o `test -f 'se/apdu.c' || echo '$(srcdir)/'`se/apdu.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-apdu.Tpo se/$(DEPDIR)/se_seeld-apdu.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/apdu.c' object='se/se_seeld-apdu.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-apdu.o `test -f 'se/apdu.c' || echo '$(srcdir)/'`se/apdu.c + +se/se_seeld-apdu.obj: se/apdu.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-apdu.obj -MD -MP -MF se/$(DEPDIR)/se_seeld-apdu.Tpo -c -o se/se_seeld-apdu.obj `if test -f 'se/apdu.c'; then $(CYGPATH_W) 'se/apdu.c'; else $(CYGPATH_W) '$(srcdir)/se/apdu.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-apdu.Tpo se/$(DEPDIR)/se_seeld-apdu.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/apdu.c' object='se/se_seeld-apdu.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-apdu.obj `if test -f 'se/apdu.c'; then $(CYGPATH_W) 'se/apdu.c'; else $(CYGPATH_W) '$(srcdir)/se/apdu.c'; fi` + +se/se_seeld-channel.o: se/channel.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-channel.o -MD -MP -MF se/$(DEPDIR)/se_seeld-channel.Tpo -c -o se/se_seeld-channel.o `test -f 'se/channel.c' || echo '$(srcdir)/'`se/channel.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-channel.Tpo se/$(DEPDIR)/se_seeld-channel.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/channel.c' object='se/se_seeld-channel.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-channel.o `test -f 'se/channel.c' || echo '$(srcdir)/'`se/channel.c + +se/se_seeld-channel.obj: se/channel.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-channel.obj -MD -MP -MF se/$(DEPDIR)/se_seeld-channel.Tpo -c -o se/se_seeld-channel.obj `if test -f 'se/channel.c'; then $(CYGPATH_W) 'se/channel.c'; else $(CYGPATH_W) '$(srcdir)/se/channel.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-channel.Tpo se/$(DEPDIR)/se_seeld-channel.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/channel.c' object='se/se_seeld-channel.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-channel.obj `if test -f 'se/channel.c'; then $(CYGPATH_W) 'se/channel.c'; else $(CYGPATH_W) '$(srcdir)/se/channel.c'; fi` + +se/se_seeld-ace.o: se/ace.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-ace.o -MD -MP -MF se/$(DEPDIR)/se_seeld-ace.Tpo -c -o se/se_seeld-ace.o `test -f 'se/ace.c' || echo '$(srcdir)/'`se/ace.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-ace.Tpo se/$(DEPDIR)/se_seeld-ace.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/ace.c' object='se/se_seeld-ace.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-ace.o `test -f 'se/ace.c' || echo '$(srcdir)/'`se/ace.c + +se/se_seeld-ace.obj: se/ace.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT se/se_seeld-ace.obj -MD -MP -MF se/$(DEPDIR)/se_seeld-ace.Tpo -c -o se/se_seeld-ace.obj `if test -f 'se/ace.c'; then $(CYGPATH_W) 'se/ace.c'; else $(CYGPATH_W) '$(srcdir)/se/ace.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) se/$(DEPDIR)/se_seeld-ace.Tpo se/$(DEPDIR)/se_seeld-ace.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='se/ace.c' object='se/se_seeld-ace.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(se_seeld_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o se/se_seeld-ace.obj `if test -f 'se/ace.c'; then $(CYGPATH_W) 'se/ace.c'; else $(CYGPATH_W) '$(srcdir)/se/ace.c'; fi` + +gdbus/src_neard-mainloop.o: gdbus/mainloop.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-mainloop.o -MD -MP -MF gdbus/$(DEPDIR)/src_neard-mainloop.Tpo -c -o gdbus/src_neard-mainloop.o `test -f 'gdbus/mainloop.c' || echo '$(srcdir)/'`gdbus/mainloop.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-mainloop.Tpo gdbus/$(DEPDIR)/src_neard-mainloop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/mainloop.c' object='gdbus/src_neard-mainloop.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-mainloop.o `test -f 'gdbus/mainloop.c' || echo '$(srcdir)/'`gdbus/mainloop.c + +gdbus/src_neard-mainloop.obj: gdbus/mainloop.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-mainloop.obj -MD -MP -MF gdbus/$(DEPDIR)/src_neard-mainloop.Tpo -c -o gdbus/src_neard-mainloop.obj `if test -f 'gdbus/mainloop.c'; then $(CYGPATH_W) 'gdbus/mainloop.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/mainloop.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-mainloop.Tpo gdbus/$(DEPDIR)/src_neard-mainloop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/mainloop.c' object='gdbus/src_neard-mainloop.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-mainloop.obj `if test -f 'gdbus/mainloop.c'; then $(CYGPATH_W) 'gdbus/mainloop.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/mainloop.c'; fi` + +gdbus/src_neard-watch.o: gdbus/watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-watch.o -MD -MP -MF gdbus/$(DEPDIR)/src_neard-watch.Tpo -c -o gdbus/src_neard-watch.o `test -f 'gdbus/watch.c' || echo '$(srcdir)/'`gdbus/watch.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-watch.Tpo gdbus/$(DEPDIR)/src_neard-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/watch.c' object='gdbus/src_neard-watch.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-watch.o `test -f 'gdbus/watch.c' || echo '$(srcdir)/'`gdbus/watch.c + +gdbus/src_neard-watch.obj: gdbus/watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-watch.obj -MD -MP -MF gdbus/$(DEPDIR)/src_neard-watch.Tpo -c -o gdbus/src_neard-watch.obj `if test -f 'gdbus/watch.c'; then $(CYGPATH_W) 'gdbus/watch.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/watch.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-watch.Tpo gdbus/$(DEPDIR)/src_neard-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/watch.c' object='gdbus/src_neard-watch.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-watch.obj `if test -f 'gdbus/watch.c'; then $(CYGPATH_W) 'gdbus/watch.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/watch.c'; fi` + +gdbus/src_neard-object.o: gdbus/object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-object.o -MD -MP -MF gdbus/$(DEPDIR)/src_neard-object.Tpo -c -o gdbus/src_neard-object.o `test -f 'gdbus/object.c' || echo '$(srcdir)/'`gdbus/object.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-object.Tpo gdbus/$(DEPDIR)/src_neard-object.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/object.c' object='gdbus/src_neard-object.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-object.o `test -f 'gdbus/object.c' || echo '$(srcdir)/'`gdbus/object.c + +gdbus/src_neard-object.obj: gdbus/object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-object.obj -MD -MP -MF gdbus/$(DEPDIR)/src_neard-object.Tpo -c -o gdbus/src_neard-object.obj `if test -f 'gdbus/object.c'; then $(CYGPATH_W) 'gdbus/object.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/object.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-object.Tpo gdbus/$(DEPDIR)/src_neard-object.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/object.c' object='gdbus/src_neard-object.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-object.obj `if test -f 'gdbus/object.c'; then $(CYGPATH_W) 'gdbus/object.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/object.c'; fi` + +gdbus/src_neard-client.o: gdbus/client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-client.o -MD -MP -MF gdbus/$(DEPDIR)/src_neard-client.Tpo -c -o gdbus/src_neard-client.o `test -f 'gdbus/client.c' || echo '$(srcdir)/'`gdbus/client.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-client.Tpo gdbus/$(DEPDIR)/src_neard-client.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/client.c' object='gdbus/src_neard-client.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-client.o `test -f 'gdbus/client.c' || echo '$(srcdir)/'`gdbus/client.c + +gdbus/src_neard-client.obj: gdbus/client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-client.obj -MD -MP -MF gdbus/$(DEPDIR)/src_neard-client.Tpo -c -o gdbus/src_neard-client.obj `if test -f 'gdbus/client.c'; then $(CYGPATH_W) 'gdbus/client.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/client.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-client.Tpo gdbus/$(DEPDIR)/src_neard-client.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/client.c' object='gdbus/src_neard-client.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-client.obj `if test -f 'gdbus/client.c'; then $(CYGPATH_W) 'gdbus/client.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/client.c'; fi` + +gdbus/src_neard-polkit.o: gdbus/polkit.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-polkit.o -MD -MP -MF gdbus/$(DEPDIR)/src_neard-polkit.Tpo -c -o gdbus/src_neard-polkit.o `test -f 'gdbus/polkit.c' || echo '$(srcdir)/'`gdbus/polkit.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-polkit.Tpo gdbus/$(DEPDIR)/src_neard-polkit.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/polkit.c' object='gdbus/src_neard-polkit.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-polkit.o `test -f 'gdbus/polkit.c' || echo '$(srcdir)/'`gdbus/polkit.c + +gdbus/src_neard-polkit.obj: gdbus/polkit.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT gdbus/src_neard-polkit.obj -MD -MP -MF gdbus/$(DEPDIR)/src_neard-polkit.Tpo -c -o gdbus/src_neard-polkit.obj `if test -f 'gdbus/polkit.c'; then $(CYGPATH_W) 'gdbus/polkit.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/polkit.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/src_neard-polkit.Tpo gdbus/$(DEPDIR)/src_neard-polkit.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/polkit.c' object='gdbus/src_neard-polkit.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o gdbus/src_neard-polkit.obj `if test -f 'gdbus/polkit.c'; then $(CYGPATH_W) 'gdbus/polkit.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/polkit.c'; fi` + +plugins/src_neard-nfctype1.o: plugins/nfctype1.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype1.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype1.Tpo -c -o plugins/src_neard-nfctype1.o `test -f 'plugins/nfctype1.c' || echo '$(srcdir)/'`plugins/nfctype1.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype1.Tpo plugins/$(DEPDIR)/src_neard-nfctype1.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype1.c' object='plugins/src_neard-nfctype1.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype1.o `test -f 'plugins/nfctype1.c' || echo '$(srcdir)/'`plugins/nfctype1.c + +plugins/src_neard-nfctype1.obj: plugins/nfctype1.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype1.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype1.Tpo -c -o plugins/src_neard-nfctype1.obj `if test -f 'plugins/nfctype1.c'; then $(CYGPATH_W) 'plugins/nfctype1.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype1.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype1.Tpo plugins/$(DEPDIR)/src_neard-nfctype1.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype1.c' object='plugins/src_neard-nfctype1.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype1.obj `if test -f 'plugins/nfctype1.c'; then $(CYGPATH_W) 'plugins/nfctype1.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype1.c'; fi` + +plugins/src_neard-nfctype2.o: plugins/nfctype2.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype2.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype2.Tpo -c -o plugins/src_neard-nfctype2.o `test -f 'plugins/nfctype2.c' || echo '$(srcdir)/'`plugins/nfctype2.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype2.Tpo plugins/$(DEPDIR)/src_neard-nfctype2.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype2.c' object='plugins/src_neard-nfctype2.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype2.o `test -f 'plugins/nfctype2.c' || echo '$(srcdir)/'`plugins/nfctype2.c + +plugins/src_neard-nfctype2.obj: plugins/nfctype2.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype2.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype2.Tpo -c -o plugins/src_neard-nfctype2.obj `if test -f 'plugins/nfctype2.c'; then $(CYGPATH_W) 'plugins/nfctype2.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype2.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype2.Tpo plugins/$(DEPDIR)/src_neard-nfctype2.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype2.c' object='plugins/src_neard-nfctype2.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype2.obj `if test -f 'plugins/nfctype2.c'; then $(CYGPATH_W) 'plugins/nfctype2.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype2.c'; fi` + +plugins/src_neard-mifare.o: plugins/mifare.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-mifare.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-mifare.Tpo -c -o plugins/src_neard-mifare.o `test -f 'plugins/mifare.c' || echo '$(srcdir)/'`plugins/mifare.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-mifare.Tpo plugins/$(DEPDIR)/src_neard-mifare.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/mifare.c' object='plugins/src_neard-mifare.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-mifare.o `test -f 'plugins/mifare.c' || echo '$(srcdir)/'`plugins/mifare.c + +plugins/src_neard-mifare.obj: plugins/mifare.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-mifare.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-mifare.Tpo -c -o plugins/src_neard-mifare.obj `if test -f 'plugins/mifare.c'; then $(CYGPATH_W) 'plugins/mifare.c'; else $(CYGPATH_W) '$(srcdir)/plugins/mifare.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-mifare.Tpo plugins/$(DEPDIR)/src_neard-mifare.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/mifare.c' object='plugins/src_neard-mifare.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-mifare.obj `if test -f 'plugins/mifare.c'; then $(CYGPATH_W) 'plugins/mifare.c'; else $(CYGPATH_W) '$(srcdir)/plugins/mifare.c'; fi` + +plugins/src_neard-nfctype3.o: plugins/nfctype3.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype3.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype3.Tpo -c -o plugins/src_neard-nfctype3.o `test -f 'plugins/nfctype3.c' || echo '$(srcdir)/'`plugins/nfctype3.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype3.Tpo plugins/$(DEPDIR)/src_neard-nfctype3.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype3.c' object='plugins/src_neard-nfctype3.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype3.o `test -f 'plugins/nfctype3.c' || echo '$(srcdir)/'`plugins/nfctype3.c + +plugins/src_neard-nfctype3.obj: plugins/nfctype3.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype3.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype3.Tpo -c -o plugins/src_neard-nfctype3.obj `if test -f 'plugins/nfctype3.c'; then $(CYGPATH_W) 'plugins/nfctype3.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype3.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype3.Tpo plugins/$(DEPDIR)/src_neard-nfctype3.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype3.c' object='plugins/src_neard-nfctype3.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype3.obj `if test -f 'plugins/nfctype3.c'; then $(CYGPATH_W) 'plugins/nfctype3.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype3.c'; fi` + +plugins/src_neard-nfctype4.o: plugins/nfctype4.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype4.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype4.Tpo -c -o plugins/src_neard-nfctype4.o `test -f 'plugins/nfctype4.c' || echo '$(srcdir)/'`plugins/nfctype4.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype4.Tpo plugins/$(DEPDIR)/src_neard-nfctype4.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype4.c' object='plugins/src_neard-nfctype4.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype4.o `test -f 'plugins/nfctype4.c' || echo '$(srcdir)/'`plugins/nfctype4.c + +plugins/src_neard-nfctype4.obj: plugins/nfctype4.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype4.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype4.Tpo -c -o plugins/src_neard-nfctype4.obj `if test -f 'plugins/nfctype4.c'; then $(CYGPATH_W) 'plugins/nfctype4.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype4.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype4.Tpo plugins/$(DEPDIR)/src_neard-nfctype4.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype4.c' object='plugins/src_neard-nfctype4.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype4.obj `if test -f 'plugins/nfctype4.c'; then $(CYGPATH_W) 'plugins/nfctype4.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype4.c'; fi` + +plugins/src_neard-nfctype5.o: plugins/nfctype5.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype5.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype5.Tpo -c -o plugins/src_neard-nfctype5.o `test -f 'plugins/nfctype5.c' || echo '$(srcdir)/'`plugins/nfctype5.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype5.Tpo plugins/$(DEPDIR)/src_neard-nfctype5.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype5.c' object='plugins/src_neard-nfctype5.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype5.o `test -f 'plugins/nfctype5.c' || echo '$(srcdir)/'`plugins/nfctype5.c + +plugins/src_neard-nfctype5.obj: plugins/nfctype5.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-nfctype5.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-nfctype5.Tpo -c -o plugins/src_neard-nfctype5.obj `if test -f 'plugins/nfctype5.c'; then $(CYGPATH_W) 'plugins/nfctype5.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype5.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-nfctype5.Tpo plugins/$(DEPDIR)/src_neard-nfctype5.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/nfctype5.c' object='plugins/src_neard-nfctype5.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-nfctype5.obj `if test -f 'plugins/nfctype5.c'; then $(CYGPATH_W) 'plugins/nfctype5.c'; else $(CYGPATH_W) '$(srcdir)/plugins/nfctype5.c'; fi` + +plugins/src_neard-p2p.o: plugins/p2p.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-p2p.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-p2p.Tpo -c -o plugins/src_neard-p2p.o `test -f 'plugins/p2p.c' || echo '$(srcdir)/'`plugins/p2p.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-p2p.Tpo plugins/$(DEPDIR)/src_neard-p2p.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/p2p.c' object='plugins/src_neard-p2p.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-p2p.o `test -f 'plugins/p2p.c' || echo '$(srcdir)/'`plugins/p2p.c + +plugins/src_neard-p2p.obj: plugins/p2p.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-p2p.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-p2p.Tpo -c -o plugins/src_neard-p2p.obj `if test -f 'plugins/p2p.c'; then $(CYGPATH_W) 'plugins/p2p.c'; else $(CYGPATH_W) '$(srcdir)/plugins/p2p.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-p2p.Tpo plugins/$(DEPDIR)/src_neard-p2p.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/p2p.c' object='plugins/src_neard-p2p.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-p2p.obj `if test -f 'plugins/p2p.c'; then $(CYGPATH_W) 'plugins/p2p.c'; else $(CYGPATH_W) '$(srcdir)/plugins/p2p.c'; fi` + +plugins/src_neard-npp.o: plugins/npp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-npp.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-npp.Tpo -c -o plugins/src_neard-npp.o `test -f 'plugins/npp.c' || echo '$(srcdir)/'`plugins/npp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-npp.Tpo plugins/$(DEPDIR)/src_neard-npp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/npp.c' object='plugins/src_neard-npp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-npp.o `test -f 'plugins/npp.c' || echo '$(srcdir)/'`plugins/npp.c + +plugins/src_neard-npp.obj: plugins/npp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-npp.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-npp.Tpo -c -o plugins/src_neard-npp.obj `if test -f 'plugins/npp.c'; then $(CYGPATH_W) 'plugins/npp.c'; else $(CYGPATH_W) '$(srcdir)/plugins/npp.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-npp.Tpo plugins/$(DEPDIR)/src_neard-npp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/npp.c' object='plugins/src_neard-npp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-npp.obj `if test -f 'plugins/npp.c'; then $(CYGPATH_W) 'plugins/npp.c'; else $(CYGPATH_W) '$(srcdir)/plugins/npp.c'; fi` + +plugins/src_neard-snep.o: plugins/snep.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-snep.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-snep.Tpo -c -o plugins/src_neard-snep.o `test -f 'plugins/snep.c' || echo '$(srcdir)/'`plugins/snep.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-snep.Tpo plugins/$(DEPDIR)/src_neard-snep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/snep.c' object='plugins/src_neard-snep.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-snep.o `test -f 'plugins/snep.c' || echo '$(srcdir)/'`plugins/snep.c + +plugins/src_neard-snep.obj: plugins/snep.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-snep.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-snep.Tpo -c -o plugins/src_neard-snep.obj `if test -f 'plugins/snep.c'; then $(CYGPATH_W) 'plugins/snep.c'; else $(CYGPATH_W) '$(srcdir)/plugins/snep.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-snep.Tpo plugins/$(DEPDIR)/src_neard-snep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/snep.c' object='plugins/src_neard-snep.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-snep.obj `if test -f 'plugins/snep.c'; then $(CYGPATH_W) 'plugins/snep.c'; else $(CYGPATH_W) '$(srcdir)/plugins/snep.c'; fi` + +plugins/src_neard-snep-validation.o: plugins/snep-validation.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-snep-validation.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-snep-validation.Tpo -c -o plugins/src_neard-snep-validation.o `test -f 'plugins/snep-validation.c' || echo '$(srcdir)/'`plugins/snep-validation.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-snep-validation.Tpo plugins/$(DEPDIR)/src_neard-snep-validation.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/snep-validation.c' object='plugins/src_neard-snep-validation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-snep-validation.o `test -f 'plugins/snep-validation.c' || echo '$(srcdir)/'`plugins/snep-validation.c + +plugins/src_neard-snep-validation.obj: plugins/snep-validation.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-snep-validation.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-snep-validation.Tpo -c -o plugins/src_neard-snep-validation.obj `if test -f 'plugins/snep-validation.c'; then $(CYGPATH_W) 'plugins/snep-validation.c'; else $(CYGPATH_W) '$(srcdir)/plugins/snep-validation.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-snep-validation.Tpo plugins/$(DEPDIR)/src_neard-snep-validation.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/snep-validation.c' object='plugins/src_neard-snep-validation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-snep-validation.obj `if test -f 'plugins/snep-validation.c'; then $(CYGPATH_W) 'plugins/snep-validation.c'; else $(CYGPATH_W) '$(srcdir)/plugins/snep-validation.c'; fi` + +plugins/src_neard-llcp-validation.o: plugins/llcp-validation.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-llcp-validation.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-llcp-validation.Tpo -c -o plugins/src_neard-llcp-validation.o `test -f 'plugins/llcp-validation.c' || echo '$(srcdir)/'`plugins/llcp-validation.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-llcp-validation.Tpo plugins/$(DEPDIR)/src_neard-llcp-validation.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/llcp-validation.c' object='plugins/src_neard-llcp-validation.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-llcp-validation.o `test -f 'plugins/llcp-validation.c' || echo '$(srcdir)/'`plugins/llcp-validation.c + +plugins/src_neard-llcp-validation.obj: plugins/llcp-validation.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-llcp-validation.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-llcp-validation.Tpo -c -o plugins/src_neard-llcp-validation.obj `if test -f 'plugins/llcp-validation.c'; then $(CYGPATH_W) 'plugins/llcp-validation.c'; else $(CYGPATH_W) '$(srcdir)/plugins/llcp-validation.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-llcp-validation.Tpo plugins/$(DEPDIR)/src_neard-llcp-validation.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/llcp-validation.c' object='plugins/src_neard-llcp-validation.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-llcp-validation.obj `if test -f 'plugins/llcp-validation.c'; then $(CYGPATH_W) 'plugins/llcp-validation.c'; else $(CYGPATH_W) '$(srcdir)/plugins/llcp-validation.c'; fi` + +plugins/src_neard-handover.o: plugins/handover.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-handover.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-handover.Tpo -c -o plugins/src_neard-handover.o `test -f 'plugins/handover.c' || echo '$(srcdir)/'`plugins/handover.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-handover.Tpo plugins/$(DEPDIR)/src_neard-handover.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/handover.c' object='plugins/src_neard-handover.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-handover.o `test -f 'plugins/handover.c' || echo '$(srcdir)/'`plugins/handover.c + +plugins/src_neard-handover.obj: plugins/handover.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-handover.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-handover.Tpo -c -o plugins/src_neard-handover.obj `if test -f 'plugins/handover.c'; then $(CYGPATH_W) 'plugins/handover.c'; else $(CYGPATH_W) '$(srcdir)/plugins/handover.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-handover.Tpo plugins/$(DEPDIR)/src_neard-handover.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/handover.c' object='plugins/src_neard-handover.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-handover.obj `if test -f 'plugins/handover.c'; then $(CYGPATH_W) 'plugins/handover.c'; else $(CYGPATH_W) '$(srcdir)/plugins/handover.c'; fi` + +plugins/src_neard-phdc.o: plugins/phdc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-phdc.o -MD -MP -MF plugins/$(DEPDIR)/src_neard-phdc.Tpo -c -o plugins/src_neard-phdc.o `test -f 'plugins/phdc.c' || echo '$(srcdir)/'`plugins/phdc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-phdc.Tpo plugins/$(DEPDIR)/src_neard-phdc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/phdc.c' object='plugins/src_neard-phdc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-phdc.o `test -f 'plugins/phdc.c' || echo '$(srcdir)/'`plugins/phdc.c + +plugins/src_neard-phdc.obj: plugins/phdc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT plugins/src_neard-phdc.obj -MD -MP -MF plugins/$(DEPDIR)/src_neard-phdc.Tpo -c -o plugins/src_neard-phdc.obj `if test -f 'plugins/phdc.c'; then $(CYGPATH_W) 'plugins/phdc.c'; else $(CYGPATH_W) '$(srcdir)/plugins/phdc.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) plugins/$(DEPDIR)/src_neard-phdc.Tpo plugins/$(DEPDIR)/src_neard-phdc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugins/phdc.c' object='plugins/src_neard-phdc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o plugins/src_neard-phdc.obj `if test -f 'plugins/phdc.c'; then $(CYGPATH_W) 'plugins/phdc.c'; else $(CYGPATH_W) '$(srcdir)/plugins/phdc.c'; fi` + +src/src_neard-main.o: src/main.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-main.o -MD -MP -MF src/$(DEPDIR)/src_neard-main.Tpo -c -o src/src_neard-main.o `test -f 'src/main.c' || echo '$(srcdir)/'`src/main.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-main.Tpo src/$(DEPDIR)/src_neard-main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/main.c' object='src/src_neard-main.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-main.o `test -f 'src/main.c' || echo '$(srcdir)/'`src/main.c + +src/src_neard-main.obj: src/main.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-main.obj -MD -MP -MF src/$(DEPDIR)/src_neard-main.Tpo -c -o src/src_neard-main.obj `if test -f 'src/main.c'; then $(CYGPATH_W) 'src/main.c'; else $(CYGPATH_W) '$(srcdir)/src/main.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-main.Tpo src/$(DEPDIR)/src_neard-main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/main.c' object='src/src_neard-main.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-main.obj `if test -f 'src/main.c'; then $(CYGPATH_W) 'src/main.c'; else $(CYGPATH_W) '$(srcdir)/src/main.c'; fi` + +src/src_neard-error.o: src/error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-error.o -MD -MP -MF src/$(DEPDIR)/src_neard-error.Tpo -c -o src/src_neard-error.o `test -f 'src/error.c' || echo '$(srcdir)/'`src/error.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-error.Tpo src/$(DEPDIR)/src_neard-error.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/error.c' object='src/src_neard-error.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-error.o `test -f 'src/error.c' || echo '$(srcdir)/'`src/error.c + +src/src_neard-error.obj: src/error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-error.obj -MD -MP -MF src/$(DEPDIR)/src_neard-error.Tpo -c -o src/src_neard-error.obj `if test -f 'src/error.c'; then $(CYGPATH_W) 'src/error.c'; else $(CYGPATH_W) '$(srcdir)/src/error.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-error.Tpo src/$(DEPDIR)/src_neard-error.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/error.c' object='src/src_neard-error.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-error.obj `if test -f 'src/error.c'; then $(CYGPATH_W) 'src/error.c'; else $(CYGPATH_W) '$(srcdir)/src/error.c'; fi` + +src/src_neard-log.o: src/log.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-log.o -MD -MP -MF src/$(DEPDIR)/src_neard-log.Tpo -c -o src/src_neard-log.o `test -f 'src/log.c' || echo '$(srcdir)/'`src/log.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-log.Tpo src/$(DEPDIR)/src_neard-log.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/log.c' object='src/src_neard-log.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-log.o `test -f 'src/log.c' || echo '$(srcdir)/'`src/log.c + +src/src_neard-log.obj: src/log.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-log.obj -MD -MP -MF src/$(DEPDIR)/src_neard-log.Tpo -c -o src/src_neard-log.obj `if test -f 'src/log.c'; then $(CYGPATH_W) 'src/log.c'; else $(CYGPATH_W) '$(srcdir)/src/log.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-log.Tpo src/$(DEPDIR)/src_neard-log.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/log.c' object='src/src_neard-log.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-log.obj `if test -f 'src/log.c'; then $(CYGPATH_W) 'src/log.c'; else $(CYGPATH_W) '$(srcdir)/src/log.c'; fi` + +src/src_neard-dbus.o: src/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-dbus.o -MD -MP -MF src/$(DEPDIR)/src_neard-dbus.Tpo -c -o src/src_neard-dbus.o `test -f 'src/dbus.c' || echo '$(srcdir)/'`src/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-dbus.Tpo src/$(DEPDIR)/src_neard-dbus.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/dbus.c' object='src/src_neard-dbus.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-dbus.o `test -f 'src/dbus.c' || echo '$(srcdir)/'`src/dbus.c + +src/src_neard-dbus.obj: src/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-dbus.obj -MD -MP -MF src/$(DEPDIR)/src_neard-dbus.Tpo -c -o src/src_neard-dbus.obj `if test -f 'src/dbus.c'; then $(CYGPATH_W) 'src/dbus.c'; else $(CYGPATH_W) '$(srcdir)/src/dbus.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-dbus.Tpo src/$(DEPDIR)/src_neard-dbus.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/dbus.c' object='src/src_neard-dbus.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-dbus.obj `if test -f 'src/dbus.c'; then $(CYGPATH_W) 'src/dbus.c'; else $(CYGPATH_W) '$(srcdir)/src/dbus.c'; fi` + +src/src_neard-manager.o: src/manager.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-manager.o -MD -MP -MF src/$(DEPDIR)/src_neard-manager.Tpo -c -o src/src_neard-manager.o `test -f 'src/manager.c' || echo '$(srcdir)/'`src/manager.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-manager.Tpo src/$(DEPDIR)/src_neard-manager.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/manager.c' object='src/src_neard-manager.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-manager.o `test -f 'src/manager.c' || echo '$(srcdir)/'`src/manager.c + +src/src_neard-manager.obj: src/manager.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-manager.obj -MD -MP -MF src/$(DEPDIR)/src_neard-manager.Tpo -c -o src/src_neard-manager.obj `if test -f 'src/manager.c'; then $(CYGPATH_W) 'src/manager.c'; else $(CYGPATH_W) '$(srcdir)/src/manager.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-manager.Tpo src/$(DEPDIR)/src_neard-manager.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/manager.c' object='src/src_neard-manager.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-manager.obj `if test -f 'src/manager.c'; then $(CYGPATH_W) 'src/manager.c'; else $(CYGPATH_W) '$(srcdir)/src/manager.c'; fi` + +src/src_neard-adapter.o: src/adapter.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-adapter.o -MD -MP -MF src/$(DEPDIR)/src_neard-adapter.Tpo -c -o src/src_neard-adapter.o `test -f 'src/adapter.c' || echo '$(srcdir)/'`src/adapter.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-adapter.Tpo src/$(DEPDIR)/src_neard-adapter.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/adapter.c' object='src/src_neard-adapter.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-adapter.o `test -f 'src/adapter.c' || echo '$(srcdir)/'`src/adapter.c + +src/src_neard-adapter.obj: src/adapter.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-adapter.obj -MD -MP -MF src/$(DEPDIR)/src_neard-adapter.Tpo -c -o src/src_neard-adapter.obj `if test -f 'src/adapter.c'; then $(CYGPATH_W) 'src/adapter.c'; else $(CYGPATH_W) '$(srcdir)/src/adapter.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-adapter.Tpo src/$(DEPDIR)/src_neard-adapter.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/adapter.c' object='src/src_neard-adapter.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-adapter.obj `if test -f 'src/adapter.c'; then $(CYGPATH_W) 'src/adapter.c'; else $(CYGPATH_W) '$(srcdir)/src/adapter.c'; fi` + +src/src_neard-device.o: src/device.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-device.o -MD -MP -MF src/$(DEPDIR)/src_neard-device.Tpo -c -o src/src_neard-device.o `test -f 'src/device.c' || echo '$(srcdir)/'`src/device.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-device.Tpo src/$(DEPDIR)/src_neard-device.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/device.c' object='src/src_neard-device.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-device.o `test -f 'src/device.c' || echo '$(srcdir)/'`src/device.c + +src/src_neard-device.obj: src/device.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-device.obj -MD -MP -MF src/$(DEPDIR)/src_neard-device.Tpo -c -o src/src_neard-device.obj `if test -f 'src/device.c'; then $(CYGPATH_W) 'src/device.c'; else $(CYGPATH_W) '$(srcdir)/src/device.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-device.Tpo src/$(DEPDIR)/src_neard-device.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/device.c' object='src/src_neard-device.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-device.obj `if test -f 'src/device.c'; then $(CYGPATH_W) 'src/device.c'; else $(CYGPATH_W) '$(srcdir)/src/device.c'; fi` + +src/src_neard-tag.o: src/tag.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-tag.o -MD -MP -MF src/$(DEPDIR)/src_neard-tag.Tpo -c -o src/src_neard-tag.o `test -f 'src/tag.c' || echo '$(srcdir)/'`src/tag.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-tag.Tpo src/$(DEPDIR)/src_neard-tag.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tag.c' object='src/src_neard-tag.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-tag.o `test -f 'src/tag.c' || echo '$(srcdir)/'`src/tag.c + +src/src_neard-tag.obj: src/tag.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-tag.obj -MD -MP -MF src/$(DEPDIR)/src_neard-tag.Tpo -c -o src/src_neard-tag.obj `if test -f 'src/tag.c'; then $(CYGPATH_W) 'src/tag.c'; else $(CYGPATH_W) '$(srcdir)/src/tag.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-tag.Tpo src/$(DEPDIR)/src_neard-tag.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tag.c' object='src/src_neard-tag.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-tag.obj `if test -f 'src/tag.c'; then $(CYGPATH_W) 'src/tag.c'; else $(CYGPATH_W) '$(srcdir)/src/tag.c'; fi` + +src/src_neard-plugin.o: src/plugin.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-plugin.o -MD -MP -MF src/$(DEPDIR)/src_neard-plugin.Tpo -c -o src/src_neard-plugin.o `test -f 'src/plugin.c' || echo '$(srcdir)/'`src/plugin.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-plugin.Tpo src/$(DEPDIR)/src_neard-plugin.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/plugin.c' object='src/src_neard-plugin.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-plugin.o `test -f 'src/plugin.c' || echo '$(srcdir)/'`src/plugin.c + +src/src_neard-plugin.obj: src/plugin.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-plugin.obj -MD -MP -MF src/$(DEPDIR)/src_neard-plugin.Tpo -c -o src/src_neard-plugin.obj `if test -f 'src/plugin.c'; then $(CYGPATH_W) 'src/plugin.c'; else $(CYGPATH_W) '$(srcdir)/src/plugin.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-plugin.Tpo src/$(DEPDIR)/src_neard-plugin.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/plugin.c' object='src/src_neard-plugin.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-plugin.obj `if test -f 'src/plugin.c'; then $(CYGPATH_W) 'src/plugin.c'; else $(CYGPATH_W) '$(srcdir)/src/plugin.c'; fi` + +src/src_neard-netlink.o: src/netlink.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-netlink.o -MD -MP -MF src/$(DEPDIR)/src_neard-netlink.Tpo -c -o src/src_neard-netlink.o `test -f 'src/netlink.c' || echo '$(srcdir)/'`src/netlink.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-netlink.Tpo src/$(DEPDIR)/src_neard-netlink.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/netlink.c' object='src/src_neard-netlink.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-netlink.o `test -f 'src/netlink.c' || echo '$(srcdir)/'`src/netlink.c + +src/src_neard-netlink.obj: src/netlink.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-netlink.obj -MD -MP -MF src/$(DEPDIR)/src_neard-netlink.Tpo -c -o src/src_neard-netlink.obj `if test -f 'src/netlink.c'; then $(CYGPATH_W) 'src/netlink.c'; else $(CYGPATH_W) '$(srcdir)/src/netlink.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-netlink.Tpo src/$(DEPDIR)/src_neard-netlink.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/netlink.c' object='src/src_neard-netlink.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-netlink.obj `if test -f 'src/netlink.c'; then $(CYGPATH_W) 'src/netlink.c'; else $(CYGPATH_W) '$(srcdir)/src/netlink.c'; fi` + +src/src_neard-ndef.o: src/ndef.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-ndef.o -MD -MP -MF src/$(DEPDIR)/src_neard-ndef.Tpo -c -o src/src_neard-ndef.o `test -f 'src/ndef.c' || echo '$(srcdir)/'`src/ndef.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-ndef.Tpo src/$(DEPDIR)/src_neard-ndef.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ndef.c' object='src/src_neard-ndef.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-ndef.o `test -f 'src/ndef.c' || echo '$(srcdir)/'`src/ndef.c + +src/src_neard-ndef.obj: src/ndef.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-ndef.obj -MD -MP -MF src/$(DEPDIR)/src_neard-ndef.Tpo -c -o src/src_neard-ndef.obj `if test -f 'src/ndef.c'; then $(CYGPATH_W) 'src/ndef.c'; else $(CYGPATH_W) '$(srcdir)/src/ndef.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-ndef.Tpo src/$(DEPDIR)/src_neard-ndef.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ndef.c' object='src/src_neard-ndef.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-ndef.obj `if test -f 'src/ndef.c'; then $(CYGPATH_W) 'src/ndef.c'; else $(CYGPATH_W) '$(srcdir)/src/ndef.c'; fi` + +src/src_neard-tlv.o: src/tlv.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-tlv.o -MD -MP -MF src/$(DEPDIR)/src_neard-tlv.Tpo -c -o src/src_neard-tlv.o `test -f 'src/tlv.c' || echo '$(srcdir)/'`src/tlv.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-tlv.Tpo src/$(DEPDIR)/src_neard-tlv.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tlv.c' object='src/src_neard-tlv.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-tlv.o `test -f 'src/tlv.c' || echo '$(srcdir)/'`src/tlv.c + +src/src_neard-tlv.obj: src/tlv.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-tlv.obj -MD -MP -MF src/$(DEPDIR)/src_neard-tlv.Tpo -c -o src/src_neard-tlv.obj `if test -f 'src/tlv.c'; then $(CYGPATH_W) 'src/tlv.c'; else $(CYGPATH_W) '$(srcdir)/src/tlv.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-tlv.Tpo src/$(DEPDIR)/src_neard-tlv.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tlv.c' object='src/src_neard-tlv.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-tlv.obj `if test -f 'src/tlv.c'; then $(CYGPATH_W) 'src/tlv.c'; else $(CYGPATH_W) '$(srcdir)/src/tlv.c'; fi` + +src/src_neard-bluetooth.o: src/bluetooth.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-bluetooth.o -MD -MP -MF src/$(DEPDIR)/src_neard-bluetooth.Tpo -c -o src/src_neard-bluetooth.o `test -f 'src/bluetooth.c' || echo '$(srcdir)/'`src/bluetooth.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-bluetooth.Tpo src/$(DEPDIR)/src_neard-bluetooth.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/bluetooth.c' object='src/src_neard-bluetooth.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-bluetooth.o `test -f 'src/bluetooth.c' || echo '$(srcdir)/'`src/bluetooth.c + +src/src_neard-bluetooth.obj: src/bluetooth.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-bluetooth.obj -MD -MP -MF src/$(DEPDIR)/src_neard-bluetooth.Tpo -c -o src/src_neard-bluetooth.obj `if test -f 'src/bluetooth.c'; then $(CYGPATH_W) 'src/bluetooth.c'; else $(CYGPATH_W) '$(srcdir)/src/bluetooth.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-bluetooth.Tpo src/$(DEPDIR)/src_neard-bluetooth.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/bluetooth.c' object='src/src_neard-bluetooth.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-bluetooth.obj `if test -f 'src/bluetooth.c'; then $(CYGPATH_W) 'src/bluetooth.c'; else $(CYGPATH_W) '$(srcdir)/src/bluetooth.c'; fi` + +src/src_neard-agent.o: src/agent.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-agent.o -MD -MP -MF src/$(DEPDIR)/src_neard-agent.Tpo -c -o src/src_neard-agent.o `test -f 'src/agent.c' || echo '$(srcdir)/'`src/agent.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-agent.Tpo src/$(DEPDIR)/src_neard-agent.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/agent.c' object='src/src_neard-agent.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-agent.o `test -f 'src/agent.c' || echo '$(srcdir)/'`src/agent.c + +src/src_neard-agent.obj: src/agent.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-agent.obj -MD -MP -MF src/$(DEPDIR)/src_neard-agent.Tpo -c -o src/src_neard-agent.obj `if test -f 'src/agent.c'; then $(CYGPATH_W) 'src/agent.c'; else $(CYGPATH_W) '$(srcdir)/src/agent.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-agent.Tpo src/$(DEPDIR)/src_neard-agent.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/agent.c' object='src/src_neard-agent.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-agent.obj `if test -f 'src/agent.c'; then $(CYGPATH_W) 'src/agent.c'; else $(CYGPATH_W) '$(srcdir)/src/agent.c'; fi` + +src/src_neard-snep.o: src/snep.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-snep.o -MD -MP -MF src/$(DEPDIR)/src_neard-snep.Tpo -c -o src/src_neard-snep.o `test -f 'src/snep.c' || echo '$(srcdir)/'`src/snep.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-snep.Tpo src/$(DEPDIR)/src_neard-snep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/snep.c' object='src/src_neard-snep.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-snep.o `test -f 'src/snep.c' || echo '$(srcdir)/'`src/snep.c + +src/src_neard-snep.obj: src/snep.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -MT src/src_neard-snep.obj -MD -MP -MF src/$(DEPDIR)/src_neard-snep.Tpo -c -o src/src_neard-snep.obj `if test -f 'src/snep.c'; then $(CYGPATH_W) 'src/snep.c'; else $(CYGPATH_W) '$(srcdir)/src/snep.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/src_neard-snep.Tpo src/$(DEPDIR)/src_neard-snep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/snep.c' object='src/src_neard-snep.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_neard_CPPFLAGS) $(CPPFLAGS) $(src_neard_CFLAGS) $(CFLAGS) -c -o src/src_neard-snep.obj `if test -f 'src/snep.c'; then $(CYGPATH_W) 'src/snep.c'; else $(CYGPATH_W) '$(srcdir)/src/snep.c'; fi` + +gdbus/tools_nfctool_nfctool-mainloop.o: gdbus/mainloop.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-mainloop.o -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-mainloop.Tpo -c -o gdbus/tools_nfctool_nfctool-mainloop.o `test -f 'gdbus/mainloop.c' || echo '$(srcdir)/'`gdbus/mainloop.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-mainloop.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-mainloop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/mainloop.c' object='gdbus/tools_nfctool_nfctool-mainloop.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-mainloop.o `test -f 'gdbus/mainloop.c' || echo '$(srcdir)/'`gdbus/mainloop.c + +gdbus/tools_nfctool_nfctool-mainloop.obj: gdbus/mainloop.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-mainloop.obj -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-mainloop.Tpo -c -o gdbus/tools_nfctool_nfctool-mainloop.obj `if test -f 'gdbus/mainloop.c'; then $(CYGPATH_W) 'gdbus/mainloop.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/mainloop.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-mainloop.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-mainloop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/mainloop.c' object='gdbus/tools_nfctool_nfctool-mainloop.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-mainloop.obj `if test -f 'gdbus/mainloop.c'; then $(CYGPATH_W) 'gdbus/mainloop.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/mainloop.c'; fi` + +gdbus/tools_nfctool_nfctool-watch.o: gdbus/watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-watch.o -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-watch.Tpo -c -o gdbus/tools_nfctool_nfctool-watch.o `test -f 'gdbus/watch.c' || echo '$(srcdir)/'`gdbus/watch.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-watch.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/watch.c' object='gdbus/tools_nfctool_nfctool-watch.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-watch.o `test -f 'gdbus/watch.c' || echo '$(srcdir)/'`gdbus/watch.c + +gdbus/tools_nfctool_nfctool-watch.obj: gdbus/watch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-watch.obj -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-watch.Tpo -c -o gdbus/tools_nfctool_nfctool-watch.obj `if test -f 'gdbus/watch.c'; then $(CYGPATH_W) 'gdbus/watch.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/watch.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-watch.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-watch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/watch.c' object='gdbus/tools_nfctool_nfctool-watch.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-watch.obj `if test -f 'gdbus/watch.c'; then $(CYGPATH_W) 'gdbus/watch.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/watch.c'; fi` + +gdbus/tools_nfctool_nfctool-object.o: gdbus/object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-object.o -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-object.Tpo -c -o gdbus/tools_nfctool_nfctool-object.o `test -f 'gdbus/object.c' || echo '$(srcdir)/'`gdbus/object.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-object.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-object.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/object.c' object='gdbus/tools_nfctool_nfctool-object.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-object.o `test -f 'gdbus/object.c' || echo '$(srcdir)/'`gdbus/object.c + +gdbus/tools_nfctool_nfctool-object.obj: gdbus/object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-object.obj -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-object.Tpo -c -o gdbus/tools_nfctool_nfctool-object.obj `if test -f 'gdbus/object.c'; then $(CYGPATH_W) 'gdbus/object.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/object.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-object.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-object.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/object.c' object='gdbus/tools_nfctool_nfctool-object.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-object.obj `if test -f 'gdbus/object.c'; then $(CYGPATH_W) 'gdbus/object.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/object.c'; fi` + +gdbus/tools_nfctool_nfctool-client.o: gdbus/client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-client.o -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-client.Tpo -c -o gdbus/tools_nfctool_nfctool-client.o `test -f 'gdbus/client.c' || echo '$(srcdir)/'`gdbus/client.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-client.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-client.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/client.c' object='gdbus/tools_nfctool_nfctool-client.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-client.o `test -f 'gdbus/client.c' || echo '$(srcdir)/'`gdbus/client.c + +gdbus/tools_nfctool_nfctool-client.obj: gdbus/client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-client.obj -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-client.Tpo -c -o gdbus/tools_nfctool_nfctool-client.obj `if test -f 'gdbus/client.c'; then $(CYGPATH_W) 'gdbus/client.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/client.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-client.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-client.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/client.c' object='gdbus/tools_nfctool_nfctool-client.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-client.obj `if test -f 'gdbus/client.c'; then $(CYGPATH_W) 'gdbus/client.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/client.c'; fi` + +gdbus/tools_nfctool_nfctool-polkit.o: gdbus/polkit.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-polkit.o -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-polkit.Tpo -c -o gdbus/tools_nfctool_nfctool-polkit.o `test -f 'gdbus/polkit.c' || echo '$(srcdir)/'`gdbus/polkit.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-polkit.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-polkit.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/polkit.c' object='gdbus/tools_nfctool_nfctool-polkit.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-polkit.o `test -f 'gdbus/polkit.c' || echo '$(srcdir)/'`gdbus/polkit.c + +gdbus/tools_nfctool_nfctool-polkit.obj: gdbus/polkit.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gdbus/tools_nfctool_nfctool-polkit.obj -MD -MP -MF gdbus/$(DEPDIR)/tools_nfctool_nfctool-polkit.Tpo -c -o gdbus/tools_nfctool_nfctool-polkit.obj `if test -f 'gdbus/polkit.c'; then $(CYGPATH_W) 'gdbus/polkit.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/polkit.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) gdbus/$(DEPDIR)/tools_nfctool_nfctool-polkit.Tpo gdbus/$(DEPDIR)/tools_nfctool_nfctool-polkit.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gdbus/polkit.c' object='gdbus/tools_nfctool_nfctool-polkit.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gdbus/tools_nfctool_nfctool-polkit.obj `if test -f 'gdbus/polkit.c'; then $(CYGPATH_W) 'gdbus/polkit.c'; else $(CYGPATH_W) '$(srcdir)/gdbus/polkit.c'; fi` + +tools/nfctool/tools_nfctool_nfctool-main.o: tools/nfctool/main.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-main.o -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-main.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-main.o `test -f 'tools/nfctool/main.c' || echo '$(srcdir)/'`tools/nfctool/main.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-main.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/main.c' object='tools/nfctool/tools_nfctool_nfctool-main.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-main.o `test -f 'tools/nfctool/main.c' || echo '$(srcdir)/'`tools/nfctool/main.c + +tools/nfctool/tools_nfctool_nfctool-main.obj: tools/nfctool/main.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-main.obj -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-main.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-main.obj `if test -f 'tools/nfctool/main.c'; then $(CYGPATH_W) 'tools/nfctool/main.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/main.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-main.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/main.c' object='tools/nfctool/tools_nfctool_nfctool-main.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-main.obj `if test -f 'tools/nfctool/main.c'; then $(CYGPATH_W) 'tools/nfctool/main.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/main.c'; fi` + +tools/nfctool/tools_nfctool_nfctool-adapter.o: tools/nfctool/adapter.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-adapter.o -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-adapter.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-adapter.o `test -f 'tools/nfctool/adapter.c' || echo '$(srcdir)/'`tools/nfctool/adapter.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-adapter.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-adapter.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/adapter.c' object='tools/nfctool/tools_nfctool_nfctool-adapter.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-adapter.o `test -f 'tools/nfctool/adapter.c' || echo '$(srcdir)/'`tools/nfctool/adapter.c + +tools/nfctool/tools_nfctool_nfctool-adapter.obj: tools/nfctool/adapter.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-adapter.obj -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-adapter.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-adapter.obj `if test -f 'tools/nfctool/adapter.c'; then $(CYGPATH_W) 'tools/nfctool/adapter.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/adapter.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-adapter.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-adapter.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/adapter.c' object='tools/nfctool/tools_nfctool_nfctool-adapter.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-adapter.obj `if test -f 'tools/nfctool/adapter.c'; then $(CYGPATH_W) 'tools/nfctool/adapter.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/adapter.c'; fi` + +tools/nfctool/tools_nfctool_nfctool-netlink.o: tools/nfctool/netlink.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-netlink.o -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-netlink.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-netlink.o `test -f 'tools/nfctool/netlink.c' || echo '$(srcdir)/'`tools/nfctool/netlink.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-netlink.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-netlink.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/netlink.c' object='tools/nfctool/tools_nfctool_nfctool-netlink.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-netlink.o `test -f 'tools/nfctool/netlink.c' || echo '$(srcdir)/'`tools/nfctool/netlink.c + +tools/nfctool/tools_nfctool_nfctool-netlink.obj: tools/nfctool/netlink.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-netlink.obj -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-netlink.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-netlink.obj `if test -f 'tools/nfctool/netlink.c'; then $(CYGPATH_W) 'tools/nfctool/netlink.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/netlink.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-netlink.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-netlink.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/netlink.c' object='tools/nfctool/tools_nfctool_nfctool-netlink.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-netlink.obj `if test -f 'tools/nfctool/netlink.c'; then $(CYGPATH_W) 'tools/nfctool/netlink.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/netlink.c'; fi` + +tools/nfctool/tools_nfctool_nfctool-sniffer.o: tools/nfctool/sniffer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-sniffer.o -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-sniffer.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-sniffer.o `test -f 'tools/nfctool/sniffer.c' || echo '$(srcdir)/'`tools/nfctool/sniffer.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-sniffer.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-sniffer.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/sniffer.c' object='tools/nfctool/tools_nfctool_nfctool-sniffer.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-sniffer.o `test -f 'tools/nfctool/sniffer.c' || echo '$(srcdir)/'`tools/nfctool/sniffer.c + +tools/nfctool/tools_nfctool_nfctool-sniffer.obj: tools/nfctool/sniffer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-sniffer.obj -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-sniffer.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-sniffer.obj `if test -f 'tools/nfctool/sniffer.c'; then $(CYGPATH_W) 'tools/nfctool/sniffer.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/sniffer.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-sniffer.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-sniffer.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/sniffer.c' object='tools/nfctool/tools_nfctool_nfctool-sniffer.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-sniffer.obj `if test -f 'tools/nfctool/sniffer.c'; then $(CYGPATH_W) 'tools/nfctool/sniffer.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/sniffer.c'; fi` + +tools/nfctool/tools_nfctool_nfctool-llcp-decode.o: tools/nfctool/llcp-decode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-llcp-decode.o -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-llcp-decode.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-llcp-decode.o `test -f 'tools/nfctool/llcp-decode.c' || echo '$(srcdir)/'`tools/nfctool/llcp-decode.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-llcp-decode.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-llcp-decode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/llcp-decode.c' object='tools/nfctool/tools_nfctool_nfctool-llcp-decode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-llcp-decode.o `test -f 'tools/nfctool/llcp-decode.c' || echo '$(srcdir)/'`tools/nfctool/llcp-decode.c + +tools/nfctool/tools_nfctool_nfctool-llcp-decode.obj: tools/nfctool/llcp-decode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-llcp-decode.obj -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-llcp-decode.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-llcp-decode.obj `if test -f 'tools/nfctool/llcp-decode.c'; then $(CYGPATH_W) 'tools/nfctool/llcp-decode.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/llcp-decode.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-llcp-decode.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-llcp-decode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/llcp-decode.c' object='tools/nfctool/tools_nfctool_nfctool-llcp-decode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-llcp-decode.obj `if test -f 'tools/nfctool/llcp-decode.c'; then $(CYGPATH_W) 'tools/nfctool/llcp-decode.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/llcp-decode.c'; fi` + +tools/nfctool/tools_nfctool_nfctool-snep-decode.o: tools/nfctool/snep-decode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-snep-decode.o -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-snep-decode.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-snep-decode.o `test -f 'tools/nfctool/snep-decode.c' || echo '$(srcdir)/'`tools/nfctool/snep-decode.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-snep-decode.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-snep-decode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/snep-decode.c' object='tools/nfctool/tools_nfctool_nfctool-snep-decode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-snep-decode.o `test -f 'tools/nfctool/snep-decode.c' || echo '$(srcdir)/'`tools/nfctool/snep-decode.c + +tools/nfctool/tools_nfctool_nfctool-snep-decode.obj: tools/nfctool/snep-decode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-snep-decode.obj -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-snep-decode.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-snep-decode.obj `if test -f 'tools/nfctool/snep-decode.c'; then $(CYGPATH_W) 'tools/nfctool/snep-decode.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/snep-decode.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-snep-decode.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-snep-decode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/snep-decode.c' object='tools/nfctool/tools_nfctool_nfctool-snep-decode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-snep-decode.obj `if test -f 'tools/nfctool/snep-decode.c'; then $(CYGPATH_W) 'tools/nfctool/snep-decode.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/snep-decode.c'; fi` + +tools/nfctool/tools_nfctool_nfctool-ndef-decode.o: tools/nfctool/ndef-decode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-ndef-decode.o -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-ndef-decode.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-ndef-decode.o `test -f 'tools/nfctool/ndef-decode.c' || echo '$(srcdir)/'`tools/nfctool/ndef-decode.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-ndef-decode.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-ndef-decode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/ndef-decode.c' object='tools/nfctool/tools_nfctool_nfctool-ndef-decode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-ndef-decode.o `test -f 'tools/nfctool/ndef-decode.c' || echo '$(srcdir)/'`tools/nfctool/ndef-decode.c + +tools/nfctool/tools_nfctool_nfctool-ndef-decode.obj: tools/nfctool/ndef-decode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-ndef-decode.obj -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-ndef-decode.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-ndef-decode.obj `if test -f 'tools/nfctool/ndef-decode.c'; then $(CYGPATH_W) 'tools/nfctool/ndef-decode.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/ndef-decode.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-ndef-decode.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-ndef-decode.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/ndef-decode.c' object='tools/nfctool/tools_nfctool_nfctool-ndef-decode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-ndef-decode.obj `if test -f 'tools/nfctool/ndef-decode.c'; then $(CYGPATH_W) 'tools/nfctool/ndef-decode.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/ndef-decode.c'; fi` + +tools/nfctool/tools_nfctool_nfctool-display.o: tools/nfctool/display.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-display.o -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-display.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-display.o `test -f 'tools/nfctool/display.c' || echo '$(srcdir)/'`tools/nfctool/display.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-display.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-display.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/display.c' object='tools/nfctool/tools_nfctool_nfctool-display.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-display.o `test -f 'tools/nfctool/display.c' || echo '$(srcdir)/'`tools/nfctool/display.c + +tools/nfctool/tools_nfctool_nfctool-display.obj: tools/nfctool/display.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/nfctool/tools_nfctool_nfctool-display.obj -MD -MP -MF tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-display.Tpo -c -o tools/nfctool/tools_nfctool_nfctool-display.obj `if test -f 'tools/nfctool/display.c'; then $(CYGPATH_W) 'tools/nfctool/display.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/display.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-display.Tpo tools/nfctool/$(DEPDIR)/tools_nfctool_nfctool-display.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/nfctool/display.c' object='tools/nfctool/tools_nfctool_nfctool-display.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/nfctool/tools_nfctool_nfctool-display.obj `if test -f 'tools/nfctool/display.c'; then $(CYGPATH_W) 'tools/nfctool/display.c'; else $(CYGPATH_W) '$(srcdir)/tools/nfctool/display.c'; fi` + +src/tools_nfctool_nfctool-log.o: src/log.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-log.o -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-log.Tpo -c -o src/tools_nfctool_nfctool-log.o `test -f 'src/log.c' || echo '$(srcdir)/'`src/log.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-log.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-log.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/log.c' object='src/tools_nfctool_nfctool-log.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-log.o `test -f 'src/log.c' || echo '$(srcdir)/'`src/log.c + +src/tools_nfctool_nfctool-log.obj: src/log.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-log.obj -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-log.Tpo -c -o src/tools_nfctool_nfctool-log.obj `if test -f 'src/log.c'; then $(CYGPATH_W) 'src/log.c'; else $(CYGPATH_W) '$(srcdir)/src/log.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-log.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-log.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/log.c' object='src/tools_nfctool_nfctool-log.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-log.obj `if test -f 'src/log.c'; then $(CYGPATH_W) 'src/log.c'; else $(CYGPATH_W) '$(srcdir)/src/log.c'; fi` + +src/tools_nfctool_nfctool-dbus.o: src/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-dbus.o -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-dbus.Tpo -c -o src/tools_nfctool_nfctool-dbus.o `test -f 'src/dbus.c' || echo '$(srcdir)/'`src/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-dbus.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-dbus.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/dbus.c' object='src/tools_nfctool_nfctool-dbus.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-dbus.o `test -f 'src/dbus.c' || echo '$(srcdir)/'`src/dbus.c + +src/tools_nfctool_nfctool-dbus.obj: src/dbus.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-dbus.obj -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-dbus.Tpo -c -o src/tools_nfctool_nfctool-dbus.obj `if test -f 'src/dbus.c'; then $(CYGPATH_W) 'src/dbus.c'; else $(CYGPATH_W) '$(srcdir)/src/dbus.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-dbus.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-dbus.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/dbus.c' object='src/tools_nfctool_nfctool-dbus.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-dbus.obj `if test -f 'src/dbus.c'; then $(CYGPATH_W) 'src/dbus.c'; else $(CYGPATH_W) '$(srcdir)/src/dbus.c'; fi` + +src/tools_nfctool_nfctool-bluetooth.o: src/bluetooth.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-bluetooth.o -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-bluetooth.Tpo -c -o src/tools_nfctool_nfctool-bluetooth.o `test -f 'src/bluetooth.c' || echo '$(srcdir)/'`src/bluetooth.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-bluetooth.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-bluetooth.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/bluetooth.c' object='src/tools_nfctool_nfctool-bluetooth.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-bluetooth.o `test -f 'src/bluetooth.c' || echo '$(srcdir)/'`src/bluetooth.c + +src/tools_nfctool_nfctool-bluetooth.obj: src/bluetooth.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-bluetooth.obj -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-bluetooth.Tpo -c -o src/tools_nfctool_nfctool-bluetooth.obj `if test -f 'src/bluetooth.c'; then $(CYGPATH_W) 'src/bluetooth.c'; else $(CYGPATH_W) '$(srcdir)/src/bluetooth.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-bluetooth.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-bluetooth.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/bluetooth.c' object='src/tools_nfctool_nfctool-bluetooth.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-bluetooth.obj `if test -f 'src/bluetooth.c'; then $(CYGPATH_W) 'src/bluetooth.c'; else $(CYGPATH_W) '$(srcdir)/src/bluetooth.c'; fi` + +src/tools_nfctool_nfctool-ndef.o: src/ndef.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-ndef.o -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-ndef.Tpo -c -o src/tools_nfctool_nfctool-ndef.o `test -f 'src/ndef.c' || echo '$(srcdir)/'`src/ndef.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-ndef.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-ndef.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ndef.c' object='src/tools_nfctool_nfctool-ndef.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-ndef.o `test -f 'src/ndef.c' || echo '$(srcdir)/'`src/ndef.c + +src/tools_nfctool_nfctool-ndef.obj: src/ndef.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-ndef.obj -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-ndef.Tpo -c -o src/tools_nfctool_nfctool-ndef.obj `if test -f 'src/ndef.c'; then $(CYGPATH_W) 'src/ndef.c'; else $(CYGPATH_W) '$(srcdir)/src/ndef.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-ndef.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-ndef.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/ndef.c' object='src/tools_nfctool_nfctool-ndef.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-ndef.obj `if test -f 'src/ndef.c'; then $(CYGPATH_W) 'src/ndef.c'; else $(CYGPATH_W) '$(srcdir)/src/ndef.c'; fi` + +src/tools_nfctool_nfctool-error.o: src/error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-error.o -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-error.Tpo -c -o src/tools_nfctool_nfctool-error.o `test -f 'src/error.c' || echo '$(srcdir)/'`src/error.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-error.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-error.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/error.c' object='src/tools_nfctool_nfctool-error.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-error.o `test -f 'src/error.c' || echo '$(srcdir)/'`src/error.c + +src/tools_nfctool_nfctool-error.obj: src/error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-error.obj -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-error.Tpo -c -o src/tools_nfctool_nfctool-error.obj `if test -f 'src/error.c'; then $(CYGPATH_W) 'src/error.c'; else $(CYGPATH_W) '$(srcdir)/src/error.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-error.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-error.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/error.c' object='src/tools_nfctool_nfctool-error.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-error.obj `if test -f 'src/error.c'; then $(CYGPATH_W) 'src/error.c'; else $(CYGPATH_W) '$(srcdir)/src/error.c'; fi` + +src/tools_nfctool_nfctool-agent.o: src/agent.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-agent.o -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-agent.Tpo -c -o src/tools_nfctool_nfctool-agent.o `test -f 'src/agent.c' || echo '$(srcdir)/'`src/agent.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-agent.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-agent.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/agent.c' object='src/tools_nfctool_nfctool-agent.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-agent.o `test -f 'src/agent.c' || echo '$(srcdir)/'`src/agent.c + +src/tools_nfctool_nfctool-agent.obj: src/agent.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/tools_nfctool_nfctool-agent.obj -MD -MP -MF src/$(DEPDIR)/tools_nfctool_nfctool-agent.Tpo -c -o src/tools_nfctool_nfctool-agent.obj `if test -f 'src/agent.c'; then $(CYGPATH_W) 'src/agent.c'; else $(CYGPATH_W) '$(srcdir)/src/agent.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/tools_nfctool_nfctool-agent.Tpo src/$(DEPDIR)/tools_nfctool_nfctool-agent.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/agent.c' object='src/tools_nfctool_nfctool-agent.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tools_nfctool_nfctool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/tools_nfctool_nfctool-agent.obj `if test -f 'src/agent.c'; then $(CYGPATH_W) 'src/agent.c'; else $(CYGPATH_W) '$(srcdir)/src/agent.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + -rm -rf se/.libs se/_libs + -rm -rf src/.libs src/_libs + -rm -rf tools/.libs tools/_libs + -rm -rf tools/nfctool/.libs tools/nfctool/_libs + -rm -rf unit/.libs unit/_libs + +distclean-libtool: + -rm -f libtool config.lt +install-man1: $(dist_man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man1dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.1[a-z]*$$/p'; \ + fi; \ + } | 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,^[^1][0-9a-z]*$$,1,;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)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$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)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) +install-man5: $(dist_man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man5dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.5[a-z]*$$/p'; \ + fi; \ + } | 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,^[^5][0-9a-z]*$$,5,;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)$(man5dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$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)$(man5dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \ + done; } + +uninstall-man5: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man5dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.5[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir) +install-man8: $(dist_man_MANS) + @$(NORMAL_INSTALL) + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man8dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.8[a-z]*$$/p'; \ + fi; \ + } | 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='$(dist_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,.,'`; \ + dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir) +install-dist_dbusDATA: $(dist_dbus_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_dbus_DATA)'; test -n "$(dbusdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(dbusdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(dbusdir)" || exit 1; \ + fi; \ + 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)$(dbusdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(dbusdir)" || exit $$?; \ + done + +uninstall-dist_dbusDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_dbus_DATA)'; test -n "$(dbusdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(dbusdir)'; $(am__uninstall_files_from_dir) +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ + 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)$(pkgconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) +install-systemdsystemunitDATA: $(systemdsystemunit_DATA) + @$(NORMAL_INSTALL) + @list='$(systemdsystemunit_DATA)'; test -n "$(systemdsystemunitdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(systemdsystemunitdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(systemdsystemunitdir)" || exit 1; \ + fi; \ + 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)$(systemdsystemunitdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(systemdsystemunitdir)" || exit $$?; \ + done + +uninstall-systemdsystemunitDATA: + @$(NORMAL_UNINSTALL) + @list='$(systemdsystemunit_DATA)'; test -n "$(systemdsystemunitdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(systemdsystemunitdir)'; $(am__uninstall_files_from_dir) +install-nodist_includeHEADERS: $(nodist_include_HEADERS) + @$(NORMAL_INSTALL) + @list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ + 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_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ + done + +uninstall-nodist_includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) +install-pkgincludeHEADERS: $(pkginclude_HEADERS) + @$(NORMAL_INSTALL) + @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ + fi; \ + 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_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ + done + +uninstall-pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + 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-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + 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" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) +clean-cscope: + -rm -f cscope.files +cscope.files: clean-cscope cscopelist +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files + +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + else \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ + done; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ + else \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + fi; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ + else \ + color_start= color_end=; \ + fi; \ + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 + +check-TESTS: + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all $(check_PROGRAMS) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +unit/test-ndef-parse.log: unit/test-ndef-parse$(EXEEXT) + @p='unit/test-ndef-parse$(EXEEXT)'; \ + b='unit/test-ndef-parse'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +unit/test-ndef-build.log: unit/test-ndef-build$(EXEEXT) + @p='unit/test-ndef-build$(EXEEXT)'; \ + b='unit/test-ndef-build'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +unit/test-snep-read.log: unit/test-snep-read$(EXEEXT) + @p='unit/test-snep-read$(EXEEXT)'; \ + b='unit/test-snep-read'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(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 + -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__post_remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 + $(am__post_remove_distdir) + +dist-lzip: distdir + tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz + $(am__post_remove_distdir) + +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz + $(am__post_remove_distdir) + +dist-tarZ: distdir + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__post_remove_distdir) + +dist-shar: distdir + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__post_remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__post_remove_distdir) + +dist dist-all: + $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' + $(am__post_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.lz*) \ + lzip -dc $(distdir).tar.lz | $(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 u+w $(distdir) + mkdir $(distdir)/_build $(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 \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + --srcdir=.. --prefix="$$dc_install_base" \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) 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__post_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: + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ + || { 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 + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(MANS) $(DATA) \ + $(HEADERS) config.h +installdirs: + for dir in "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(se_plugindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkglibexecdir)" "$(DESTDIR)$(testdir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(dbusdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(systemdsystemunitdir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(pkgincludedir)"; 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: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + +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) + -rm -f gdbus/$(DEPDIR)/$(am__dirstamp) + -rm -f gdbus/$(am__dirstamp) + -rm -f plugins/$(DEPDIR)/$(am__dirstamp) + -rm -f plugins/$(am__dirstamp) + -rm -f se/$(DEPDIR)/$(am__dirstamp) + -rm -f se/$(am__dirstamp) + -rm -f se/plugins/$(DEPDIR)/$(am__dirstamp) + -rm -f se/plugins/$(am__dirstamp) + -rm -f src/$(DEPDIR)/$(am__dirstamp) + -rm -f src/$(am__dirstamp) + -rm -f tools/$(DEPDIR)/$(am__dirstamp) + -rm -f tools/$(am__dirstamp) + -rm -f tools/nfctool/$(DEPDIR)/$(am__dirstamp) + -rm -f tools/nfctool/$(am__dirstamp) + -rm -f unit/$(DEPDIR)/$(am__dirstamp) + -rm -f unit/$(am__dirstamp) + -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) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ + clean-libtool clean-local clean-noinstPROGRAMS \ + clean-pkglibexecPROGRAMS clean-pluginLTLIBRARIES \ + clean-se_pluginLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf gdbus/$(DEPDIR) plugins/$(DEPDIR) se/$(DEPDIR) se/plugins/$(DEPDIR) src/$(DEPDIR) tools/$(DEPDIR) tools/nfctool/$(DEPDIR) unit/$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-dist_dbusDATA install-man \ + install-nodist_includeHEADERS install-pkgconfigDATA \ + install-pkgincludeHEADERS install-pluginLTLIBRARIES \ + install-se_pluginLTLIBRARIES install-systemdsystemunitDATA \ + install-testSCRIPTS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS install-pkglibexecPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: install-man1 install-man5 install-man8 + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf gdbus/$(DEPDIR) plugins/$(DEPDIR) se/$(DEPDIR) se/plugins/$(DEPDIR) src/$(DEPDIR) tools/$(DEPDIR) tools/nfctool/$(DEPDIR) unit/$(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-binPROGRAMS uninstall-dist_dbusDATA \ + uninstall-man uninstall-nodist_includeHEADERS \ + uninstall-pkgconfigDATA uninstall-pkgincludeHEADERS \ + uninstall-pkglibexecPROGRAMS uninstall-pluginLTLIBRARIES \ + uninstall-se_pluginLTLIBRARIES uninstall-systemdsystemunitDATA \ + uninstall-testSCRIPTS + +uninstall-man: uninstall-man1 uninstall-man5 uninstall-man8 + +.MAKE: all check check-am install install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-TESTS \ + check-am clean clean-binPROGRAMS clean-checkPROGRAMS \ + clean-cscope clean-generic clean-libtool clean-local \ + clean-noinstPROGRAMS clean-pkglibexecPROGRAMS \ + clean-pluginLTLIBRARIES clean-se_pluginLTLIBRARIES cscope \ + cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ + dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ + distcheck distclean distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags distcleancheck \ + distdir distuninstallcheck dvi dvi-am html html-am info \ + info-am install install-am install-binPROGRAMS install-data \ + install-data-am install-dist_dbusDATA install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-man1 install-man5 install-man8 \ + install-nodist_includeHEADERS install-pdf install-pdf-am \ + install-pkgconfigDATA install-pkgincludeHEADERS \ + install-pkglibexecPROGRAMS install-pluginLTLIBRARIES \ + install-ps install-ps-am install-se_pluginLTLIBRARIES \ + install-strip install-systemdsystemunitDATA \ + install-testSCRIPTS installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am recheck tags tags-am uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-dist_dbusDATA \ + uninstall-man uninstall-man1 uninstall-man5 uninstall-man8 \ + uninstall-nodist_includeHEADERS uninstall-pkgconfigDATA \ + uninstall-pkgincludeHEADERS uninstall-pkglibexecPROGRAMS \ + uninstall-pluginLTLIBRARIES uninstall-se_pluginLTLIBRARIES \ + uninstall-systemdsystemunitDATA uninstall-testSCRIPTS + + +%.service: %.service.in Makefile + $(SED_PROCESS) + +src/plugin.$(OBJEXT): src/builtin.h + +src/builtin.h: src/genbuiltin $(builtin_sources) + $(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@ + +se/plugin.$(OBJEXT): se/builtin.h + +se/builtin.h: src/genbuiltin $(builtin_se_sources) + $(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_se_modules) > $@ + +$(src_neard_OBJECTS) \ +$(tools_nfctool_nfctool_OBJECTS) \ +$(plugin_objects) \ +$(se_seeld_OBJECTS) \ +$(unit_test_ndef_parse_OBJECTS) \ +$(unit_test_ndef_build_OBJECTS) \ +$(unit_test_snep-read_OBJECTS) \ +$(tools_snep_send_OBJECTS): $(local_headers) + +include/near/version.h: include/version.h + $(AM_V_at)$(MKDIR_P) include/near + $(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$< $@ + +include/near/%.h: $(abs_top_srcdir)/include/%.h + $(AM_V_at)$(MKDIR_P) include/near + $(AM_V_GEN)$(LN_S) $< $@ + +clean-local: + @$(RM) -rf include/near + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT:
diff --git a/neard/Makefile.plugins b/neard/Makefile.plugins new file mode 100644 index 0000000..1d74570 --- /dev/null +++ b/neard/Makefile.plugins
@@ -0,0 +1,46 @@ + +plugin_cflags = -fvisibility=hidden -I$(srcdir)/gdbus \ + @DBUS_CFLAGS@ @GLIB_CFLAGS@ +plugin_ldflags = -no-undefined -module -avoid-version + +if NFCTYPE1 +builtin_modules += nfctype1 +builtin_sources += plugins/nfctype1.c +endif + +if NFCTYPE2 +builtin_modules += nfctype2 +builtin_sources += plugins/nfctype2.c plugins/mifare.c +endif + +if NFCTYPE3 +builtin_modules += nfctype3 +builtin_sources += plugins/nfctype3.c +endif + +if NFCTYPE4 +builtin_modules += nfctype4 +builtin_sources += plugins/nfctype4.c +endif + +if NFCTYPE5 +builtin_modules += nfctype5 +builtin_sources += plugins/nfctype5.c +endif + +if P2P +builtin_modules += p2p +builtin_sources += plugins/p2p.c plugins/npp.c \ + plugins/snep.c \ + plugins/snep-validation.c \ + plugins/llcp-validation.c \ + plugins/handover.c plugins/p2p.h \ + plugins/phdc.c +endif + +if SE +builtin_se_modules += nfc +builtin_se_sources += se/plugins/nfc.c +builtin_se_cflags += @NETLINK_CFLAGS@ +builtin_se_libadd += @NETLINK_LIBS@ +endif
diff --git a/neard/NEWS b/neard/NEWS new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/neard/NEWS
diff --git a/neard/README b/neard/README new file mode 100644 index 0000000..8204b69 --- /dev/null +++ b/neard/README
@@ -0,0 +1,56 @@ +Near Field Communication manager +******************************** + +Copyright (C) 2011 Intel Corporation. All rights reserved. + + +Compilation and installation +============================ + +In order to compile neard you need following software packages: + - GCC compiler + - D-Bus library + - GLib library + - Netlink (libnl) library, version 1 or 2. + +To configure run: + ./configure --prefix=/usr + +Configure automatically searches for all required components and packages. + +To compile and install run: + make && make install + +Configuration and options +========================= + +By default all neard plugins and features are built in. They can be +disabled with the following configuration options: + + --disable-nfctype1 + + Disable support for type 1 NFC tags. + + --disable-nfctype2 + + Disable support for type 2 NFC tags. + + --disable-nfctype3 + + Disable support for type 3 NFC tags. + + --disable-nfctype4 + + Disable support for type 1 NFC tags. + + --disable-nfctype5 + + Disable support for type 5 ISO 15693 tags. + + --disable-p2p + + Disable support for peer to peer mode. + +Running ./bootstrap-configure will build the configure script and then +run it, with maintainer mode enabled. bootstrap-configure will configure +neard with all features enabled.
diff --git a/neard/TODO b/neard/TODO new file mode 100644 index 0000000..352b2c1 --- /dev/null +++ b/neard/TODO
@@ -0,0 +1,108 @@ +Background +========== + +- Priority scale: High, Medium and Low + +- Complexity scale: C1, C2, C4 and C8. + The complexity scale is exponential, with complexity 1 being the + lowest complexity. Complexity is a function of both task 'complexity' + and task 'scope'. + +Core +==== + +- Card Emulation Mode + + Priority: Low + Complexity: C8 + Dependencies: Core:NDEF building library + Owner: Samuel Ortiz <sameo@linux.intel.com> + + In card emulation mode, the NFC adapter is in passive mode, and gets + activated by an initiator mode device. Then the initiator sends command + that the target is supposed to interpret and respond to. Most of the + commands are tag specific. + For a proper card emulation mode support, the NFC adapter must enter the + polling loop and not only initiate the RF field, but then wait for intiator + to activate it. Once activated, the NFC socket should enter the accept + state, and dispatch the various commands to the right plugins (one per + protocol, a.k.a. tags). + +- Packaging + + Priority: Medium + Complexity: C2 + Owner: Samuel Ortiz <sameo@linux.intel.com> + + Packaging for both RPM packages based distributions should be done in order + to push neard into the mainstream Linux distributions. + +- OBEX over LLCP + + Priority: Medium + Complexity: C4 + Owner: Samuel Ortiz <sameo@linux.intel.com> + +- Split NDEF code + + Priority: Low + Complexity: C4 + Owner: + + NDEF code (Handover related in particular) should be splitted into parsing and + acting part. This would make code easier to follow and would also allow to + run unit tests on parsing part. + + +Reader mode +=========== + + +Writer mode +=========== + +- MIFARE writer mode support + + Priority: Low + Complexity: C2 + Owner: Dorota Moskal <dorota.moskal@tieto.com> + + +p2p mode +======== + +- SNEP and LLCP validation tests + + Priority: Medium + Complexity: C4 + Owner: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com> + + Implement SNEP validation test cases as an optional neard plugin, and + LLCP ones as a set of tools/ binaries. + +- Microsoft handover + + Priority: Low + Complexity: C4 + Owner: Samuel Ortiz <sameo@linux.intel.com> + + Microsoft handover implementation does not follow the NFC Forum specs. + It is specified here: + + http://msdn.microsoft.com/en-us/library/ee941641 + + In order to support this handover implementation, a specific plugin + should be implemented as there is no overlap between it and the NFC + Forum handover. + +- PHDC service + + Priority: Medium + Complexity: C4 + Owner: Olivier Guiter <olivier.guiter@intel.com> + + PHDC (Personal Health Device Communication) is a protocol on top of LLCP + for exchanging ISO/IEEE 11073 PDUs. It has its own LLCP service name and + as such could be implemented as a p2p plugin. + The PHDC plugin would define its own D-Bus interface for the PHDC Manager + role.
diff --git a/neard/acinclude.m4 b/neard/acinclude.m4 new file mode 100644 index 0000000..fbc7660 --- /dev/null +++ b/neard/acinclude.m4
@@ -0,0 +1,27 @@ +AC_DEFUN([NEARD_PROG_CC_PIE], [ + AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], neard_cv_prog_cc_pie, [ + echo 'void f(){}' > conftest.c + if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then + neard_cv_prog_cc_pie=yes + else + neard_cv_prog_cc_pie=no + fi + rm -rf conftest* + ]) +]) + +AC_DEFUN([NEARD_COMPILER_FLAGS], [ + if (test "${CFLAGS}" = ""); then + CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2" + fi + if (test "$USE_MAINTAINER_MODE" = "yes"); then + CFLAGS+=" -Werror -Wextra" + CFLAGS+=" -Wno-unused-parameter" + CFLAGS+=" -Wno-missing-field-initializers" + CFLAGS+=" -Wdeclaration-after-statement" + CFLAGS+=" -Wmissing-declarations" + CFLAGS+=" -Wredundant-decls" + CFLAGS+=" -Wcast-align" + CFLAGS+=" -DG_DISABLE_DEPRECATED" + fi +])
diff --git a/neard/aclocal.m4 b/neard/aclocal.m4 new file mode 100644 index 0000000..7f2a607 --- /dev/null +++ b/neard/aclocal.m4
@@ -0,0 +1,1351 @@ +# generated automatically by aclocal 1.14.1 -*- Autoconf -*- + +# Copyright (C) 1996-2013 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_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. +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'.])]) + +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) +# +# Copyright © 2004 Scott James Remnant <scott@netsplit.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. +# +# 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 <http://pkg-config.freedesktop.org/>.])[]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-2013 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.14' +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.14.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.14.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-2013 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-2013 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_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ([2.52])dnl + m4_if([$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-2013 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. + + +# 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", "OBJC", "OBJCXX", "UPC", or "GJC". +# 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 + +m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], + [$1], [CXX], [depcc="$CXX" am_compiler_list=], + [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], [OBJCXX], [depcc="$OBJCXX" 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". + rm -rf conftest.dir + 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 10 /bin/sh. + echo '/* dummy */' > 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 + ;; + msvc7 | msvc7msys | 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], [dnl +AS_HELP_STRING( + [--enable-dependency-tracking], + [do not reject slow dependency extractors]) +AS_HELP_STRING( + [--disable-dependency-tracking], + [speeds up one-time build])]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +AC_SUBST([am__nodep])dnl +_AM_SUBST_NOTMAKE([am__nodep])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999-2013 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_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Older Autoconf 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"` + # 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'`; 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-2013 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 macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. +m4_define([AC_PROG_CC], +m4_defn([AC_PROG_CC]) +[_AM_PROG_CC_C_O +]) + +# 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.65])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], +[AC_DIAGNOSE([obsolete], + [$0: two- and three-arguments forms are deprecated.]) +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], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + [ok:ok],, + [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([AC_PROG_MKDIR_P])dnl +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> +# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> +AC_SUBST([mkdir_p], ['$(MKDIR_P)']) +# 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])], + [m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES([CXX])], + [m4_define([AC_PROG_CXX], + m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES([OBJC])], + [m4_define([AC_PROG_OBJC], + m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], + [_AM_DEPENDENCIES([OBJCXX])], + [m4_define([AC_PROG_OBJCXX], + m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl +]) +AC_REQUIRE([AM_SILENT_RULES])dnl +dnl The testsuite driver may need to know about EXEEXT, so add the +dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This +dnl macro 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 + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542> + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: <http://www.gnu.org/software/coreutils/>. + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) + fi +fi]) + +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-2013 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-2013 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. + +# 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])]) + +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# Copyright (C) 1996-2013 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_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless 'enable' is passed literally. +# For symmetry, 'disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], + [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], + am_maintainer_other[ make rules and dependencies not useful + (and sometimes confusing) to the casual installer])], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001-2013 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_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 +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997-2013 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_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 is modern enough. +# If it is, 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 --is-lightweight"; then + am_missing_run="$MISSING " +else + am_missing_run= + AC_MSG_WARN(['missing' script is too old or missing]) +fi +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001-2013 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_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])]) + +# Copyright (C) 1999-2013 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_CC_C_O +# --------------- +# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC +# to automatically call this. +AC_DEFUN([_AM_PROG_CC_C_O], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([compile])dnl +AC_LANG_PUSH([C])dnl +AC_CACHE_CHECK( + [whether $CC understands -c and -o together], + [am_cv_prog_cc_c_o], + [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i]) +if test "$am_cv_prog_cc_c_o" != 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 +AC_LANG_POP([C])]) + +# For backward compatibility. +AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) + +# Copyright (C) 2001-2013 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_RUN_LOG(COMMAND) +# ------------------- +# Run COMMAND, save the exit status in ac_status, and log it. +# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) +AC_DEFUN([AM_RUN_LOG], +[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD + ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + (exit $ac_status); }]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996-2013 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_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# 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 ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + 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 + 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 + if test "$[2]" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + 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]) +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi +AC_CONFIG_COMMANDS_PRE( + [AC_MSG_CHECKING([that generated files are newer than configure]) + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + AC_MSG_RESULT([done])]) +rm -f conftest.file +]) + +# Copyright (C) 2009-2013 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_SILENT_RULES([DEFAULT]) +# -------------------------- +# Enable less verbose build rules; with the default set to DEFAULT +# ("yes" being less verbose, "no" or empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_ARG_ENABLE([silent-rules], [dnl +AS_HELP_STRING( + [--enable-silent-rules], + [less verbose build output (undo: "make V=1")]) +AS_HELP_STRING( + [--disable-silent-rules], + [verbose build output (undo: "make V=0")])dnl +]) +case $enable_silent_rules in @%:@ ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +esac +dnl +dnl A few 'make' implementations (e.g., NonStop OS and NextStep) +dnl do not support nested variable expansions. +dnl See automake bug#9928 and bug#10237. +am_make=${MAKE-make} +AC_CACHE_CHECK([whether $am_make supports nested variables], + [am_cv_make_support_nested_variables], + [if AS_ECHO([['TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi]) +if test $am_cv_make_support_nested_variables = yes; then + dnl Using '$V' instead of '$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AC_SUBST([AM_V])dnl +AM_SUBST_NOTMAKE([AM_V])dnl +AC_SUBST([AM_DEFAULT_V])dnl +AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl +AC_SUBST([AM_DEFAULT_VERBOSITY])dnl +AM_BACKSLASH='\' +AC_SUBST([AM_BACKSLASH])dnl +_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +]) + +# Copyright (C) 2001-2013 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-2013 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# 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-2013 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_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. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' + +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + + [m4_case([$1], + [ustar], + [# The POSIX 1988 'ustar' format is defined with fixed-size fields. + # There is notably a 21 bits limit for the UID and the GID. In fact, + # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 + # and bug#13588). + am_max_uid=2097151 # 2^21 - 1 + am_max_gid=$am_max_uid + # The $UID and $GID variables are not portable, so we need to resort + # to the POSIX-mandated id(1) utility. Errors in the 'id' calls + # below are definitely unexpected, so allow the users to see them + # (that is, avoid stderr redirection). + am_uid=`id -u || echo unknown` + am_gid=`id -g || echo unknown` + AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) + if test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi + AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) + if test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi], + + [pax], + [], + + [m4_fatal([Unknown tar format])]) + + AC_MSG_CHECKING([how to create a $1 tar archive]) + + # Go ahead even if we have the value already cached. We do so because we + # need to set the values for the 'am__tar' and 'am__untar' variables. + _am_tools=${am_cv_prog_tar_$1-$_am_tools} + + 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 <conftest.tar]) + AM_RUN_LOG([cat conftest.dir/file]) + grep GrepMe conftest.dir/file >/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/libtool.m4]) +m4_include([m4/ltoptions.m4]) +m4_include([m4/ltsugar.m4]) +m4_include([m4/ltversion.m4]) +m4_include([m4/lt~obsolete.m4]) +m4_include([acinclude.m4])
diff --git a/neard/bootstrap b/neard/bootstrap new file mode 100755 index 0000000..cb2974e --- /dev/null +++ b/neard/bootstrap
@@ -0,0 +1,5 @@ +#!/bin/sh + +mkdir -p m4 +autoreconf -fi +rm -Rf autom4te.cache
diff --git a/neard/bootstrap-configure b/neard/bootstrap-configure new file mode 100755 index 0000000..7cb1458 --- /dev/null +++ b/neard/bootstrap-configure
@@ -0,0 +1,14 @@ +#!/bin/sh + +if [ -f config.status ]; then + make maintainer-clean +fi + +./bootstrap && \ + ./configure --enable-maintainer-mode \ + --enable-debug \ + --disable-systemd \ + --prefix=/usr \ + --enable-ese \ + --sysconfdir=/etc \ + --enable-tools "$@"
diff --git a/neard/compile b/neard/compile new file mode 100755 index 0000000..531136b --- /dev/null +++ b/neard/compile
@@ -0,0 +1,347 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2012-10-14.11; # UTC + +# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Written by Tom Tromey <tromey@cygnus.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, 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 <http://www.gnu.org/licenses/>. + +# 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 <bug-automake@gnu.org> or send patches to +# <automake-patches@gnu.org>. + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + 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'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +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 <bug-automake@gnu.org>. +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +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:
diff --git a/neard/config.guess b/neard/config.guess new file mode 100755 index 0000000..b79252d --- /dev/null +++ b/neard/config.guess
@@ -0,0 +1,1558 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2013 Free Software Foundation, Inc. + +timestamp='2013-06-10' + +# 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 3 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, see <http://www.gnu.org/licenses/>. +# +# 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 Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner. +# +# 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 +# +# Please send patches with a ChangeLog entry to config-patches@gnu.org. + + +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 <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2013 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 + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include <features.h> + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + ;; +esac + +# 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 tuples: *-*-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 ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_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 <stdio.h> /* 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 <sys/systemcfg.h> + + 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 <stdlib.h> + #include <unistd.h> + + 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 <unistd.h> + 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:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + 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-${LIBC}`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/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + 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="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${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-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + 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-${LIBC}"; exit; } + ;; + or1k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + 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' </usr/options/cb.name` + echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + elif /bin/uname -X 2>/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 <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # 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 ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-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 + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + 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 + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + 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 ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; +esac + +eval $set_cc_for_build +cat >$dummy.c <<EOF +#ifdef _SEQUENT_ +# include <sys/types.h> +# include <sys/utsname.h> +#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 <sys/param.h> + 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 <sys/param.h> +# 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 <<EOF +$0: unable to guess system type + +This script, last modified $timestamp, has failed to recognize +the operating system you are using. It is advised that you +download the most up to date version of the config scripts from + + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +and + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +If the version you run ($0) is already up to date, please +send the following data and any information you think might be +pertinent to <config-patches@gnu.org> in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End:
diff --git a/neard/config.h.in b/neard/config.h.in new file mode 100644 index 0000000..b1e101d --- /dev/null +++ b/neard/config.h.in
@@ -0,0 +1,65 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Define to 1 if you need libnl-1 compat functions. */ +#undef NEED_LIBNL_COMPAT + +/* 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 + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION
diff --git a/neard/config.sub b/neard/config.sub new file mode 100755 index 0000000..9633db7 --- /dev/null +++ b/neard/config.sub
@@ -0,0 +1,1791 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2013 Free Software Foundation, Inc. + +timestamp='2013-08-10' + +# 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 3 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, see <http://www.gnu.org/licenses/>. +# +# 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 Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches with a ChangeLog entry to config-patches@gnu.org. +# +# 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 <config-patches@gnu.org>." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2013 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-musl* | 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/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + 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*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -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 \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | epiphany \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | 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 \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 \ + | or1k | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pyramid \ + | rl78 | 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 | v850e1 | v850e2 | v850es | v850e2v3 \ + | 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 | m68hcs12x | picochip) + 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 + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + 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-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | 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-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | 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-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pyramid-* \ + | rl78-* | 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*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | 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*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 + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-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-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + 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 | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + 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 + ;; + tile*) + basic_machine=$basic_machine-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* | -plan9* \ + | -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* \ + | -bitrig* | -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* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -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 + ;; + -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 + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + 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 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or1k-*) + 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:
diff --git a/neard/configure b/neard/configure new file mode 100755 index 0000000..c27c6c0 --- /dev/null +++ b/neard/configure
@@ -0,0 +1,15112 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for neard 0.15. +# +# Report bugs to <linux-nfc@lists.01.org>. +# +# +# Copyright (C) 1992-1996, 1998-2012 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 + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # 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 +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+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +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 +test -x / || 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 : + export CONFIG_SHELL + # 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 +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+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +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 and +$0: linux-nfc@lists.01.org about your system, including any +$0: error possibly output before this message. Then install +$0: a modern shell, or manually run the script under such a +$0: 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_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_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; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # 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 -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +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 + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# 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 </dev/null +exec 6>&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='neard' +PACKAGE_TARNAME='neard' +PACKAGE_VERSION='0.15' +PACKAGE_STRING='neard 0.15' +PACKAGE_BUGREPORT='linux-nfc@lists.01.org' +PACKAGE_URL='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include <stdio.h> +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#ifdef STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# ifdef HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif" + +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBOBJS +SE_FALSE +SE_TRUE +ESE_FALSE +ESE_TRUE +P2P_FALSE +P2P_TRUE +NFCTYPE5_FALSE +NFCTYPE5_TRUE +NFCTYPE4_FALSE +NFCTYPE4_TRUE +NFCTYPE3_FALSE +NFCTYPE3_TRUE +NFCTYPE2_FALSE +NFCTYPE2_TRUE +NFCTYPE1_FALSE +NFCTYPE1_TRUE +TOOLS_FALSE +TOOLS_TRUE +TEST_FALSE +TEST_TRUE +NETLINK_DEPS +NETLINK_LIBS +NETLINK_CFLAGS +LIBNL1_LIBS +LIBNL1_CFLAGS +LIBNL2_LIBS +LIBNL2_CFLAGS +LIBNL3_LIBS +LIBNL3_CFLAGS +DBUS_DEPS +DBUS_LIBS +DBUS_CFLAGS +GLIB_DEPS +GLIB_LIBS +GLIB_CFLAGS +SYSTEMD_USERUNITDIR +SYSTEMD_SYSTEMUNITDIR +SYSTEMD_FALSE +SYSTEMD_TRUE +READLINE_FALSE +READLINE_TRUE +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 +am__nodep +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG +se_plugindir +plugindir +MAINT +MAINTAINER_MODE_FALSE +MAINTAINER_MODE_TRUE +AM_BACKSLASH +AM_DEFAULT_VERBOSITY +AM_DEFAULT_V +AM_V +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_silent_rules +enable_maintainer_mode +enable_dependency_tracking +enable_static +enable_shared +with_pic +enable_fast_install +with_gnu_ld +with_sysroot +enable_libtool_lock +enable_systemd +with_systemdsystemunitdir +with_systemduserunitdir +enable_optimization +enable_debug +enable_pie +enable_test +enable_tools +enable_nfctype1 +enable_nfctype2 +enable_nfctype3 +enable_nfctype4 +enable_nfctype5 +enable_p2p +enable_ese +' + ac_precious_vars='build_alias +host_alias +target_alias +PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +GLIB_CFLAGS +GLIB_LIBS +DBUS_CFLAGS +DBUS_LIBS +LIBNL3_CFLAGS +LIBNL3_LIBS +LIBNL2_CFLAGS +LIBNL2_LIBS +LIBNL1_CFLAGS +LIBNL1_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_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) 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 + 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 neard 0.15 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/neard] + --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 + case $ac_init_help in + short | recursive ) echo "Configuration of neard 0.15:";; + esac + 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] + --enable-silent-rules less verbose build output (undo: "make V=1") + --disable-silent-rules verbose build output (undo: "make V=0") + --enable-maintainer-mode + enable make rules and dependencies not useful (and + sometimes confusing) to the casual installer + --enable-dependency-tracking + do not reject slow dependency extractors + --disable-dependency-tracking + speeds up one-time build + --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-systemd disable systemd integration + --disable-optimization disable code optimization through compiler + --enable-debug enable compiling with debugging information + --enable-pie enable position independent executables flag + --enable-test enable test/example scripts + --enable-tools enable testing tools + --disable-nfctype1 disable NFC forum type 1 tags support + --disable-nfctype2 disable NFC forum type 2 tags support + --disable-nfctype3 disable NFC forum type 3 tags support + --disable-nfctype4 disable NFC forum type 4 tags support + --disable-nfctype5 disable NFC forum type 5 tags support + --disable-p2p disable NFC peer to peer support + --enable-ese enable embedded SE support + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-pic[=PKGS] 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-systemdsystemunitdir=DIR + path to systemd system unit directory + --with-systemduserunitdir=DIR + path to systemd user unit directory + +Some influential environment variables: + 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 + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + LIBS libraries to pass to the linker, e.g. -l<library> + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if + you have headers in a nonstandard directory <include dir> + CPP C preprocessor + GLIB_CFLAGS C compiler flags for GLIB, overriding pkg-config + GLIB_LIBS linker flags for GLIB, overriding pkg-config + DBUS_CFLAGS C compiler flags for DBUS, overriding pkg-config + DBUS_LIBS linker flags for DBUS, overriding pkg-config + LIBNL3_CFLAGS + C compiler flags for LIBNL3, overriding pkg-config + LIBNL3_LIBS linker flags for LIBNL3, overriding pkg-config + LIBNL2_CFLAGS + C compiler flags for LIBNL2, overriding pkg-config + LIBNL2_LIBS linker flags for LIBNL2, overriding pkg-config + LIBNL1_CFLAGS + C compiler flags for LIBNL1, overriding pkg-config + LIBNL1_LIBS linker flags for LIBNL1, 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 <linux-nfc@lists.01.org>. +_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 +neard configure 0.15 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 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 || + 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 <limits.h> declares $2. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#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 +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by neard $as_me 0.15, which was +generated by GNU Autoconf 2.69. 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 + + + + +am__api_version='1.14' + +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 as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + 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; } +# 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 ( + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + 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 + 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 + if test "$2" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done + 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; } +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi + +rm -f conftest.file + +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 --is-lightweight"; then + am_missing_run="$MISSING " +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 as_fn_executable_p "$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 as_fn_executable_p "$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 + as_fn_executable_p "$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; } + +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 as_fn_executable_p "$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 + +# Check whether --enable-silent-rules was given. +if test "${enable_silent_rules+set}" = set; then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=1;; +esac +am_make=${MAKE-make} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +$as_echo_n "checking whether $am_make supports nested variables... " >&6; } +if ${am_cv_make_support_nested_variables+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $as_echo 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +$as_echo "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + +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='neard' + VERSION='0.15' + + +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"} + +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> +# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> +mkdir_p='$(MKDIR_P)' + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' + + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar pax cpio none' + +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' + + + + + + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542> + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: <http://www.gnu.org/software/coreutils/>. + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 + fi +fi +ac_config_headers="$ac_config_headers config.h" + + +# Check whether --enable-silent-rules was given. +if test "${enable_silent_rules+set}" = set; then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=0;; +esac +am_make=${MAKE-make} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +$as_echo_n "checking whether $am_make supports nested variables... " >&6; } +if ${am_cv_make_support_nested_variables+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $as_echo 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +$as_echo "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 +$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } + # Check whether --enable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then : + enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 +$as_echo "$USE_MAINTAINER_MODE" >&6; } + if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE + + + +# Do not expand the default variables so that they can be changed at build +# time, in the make command-line. +if (test "${libdir}" = '${exec_prefix}/lib'); then + libdir='${prefix}/lib' +fi + +plugindir='${pkglibdir}/plugins' +se_plugindir='${pkglibdir}/plugins-se' + + + + + + + + + + +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 as_fn_executable_p "$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 as_fn_executable_p "$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 + + + if (test "${CFLAGS}" = ""); then + CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2" + fi + if (test "$USE_MAINTAINER_MODE" = "yes"); then + CFLAGS+=" -Werror -Wextra" + CFLAGS+=" -Wno-unused-parameter" + CFLAGS+=" -Wno-missing-field-initializers" + CFLAGS+=" -Wdeclaration-after-statement" + CFLAGS+=" -Wmissing-declarations" + CFLAGS+=" -Wredundant-decls" + CFLAGS+=" -Wcast-align" + CFLAGS+=" -DG_DISABLE_DEPRECATED" + 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 + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $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 + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $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 + + 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 +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $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 + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $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 + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $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 + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $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 + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $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 as_fn_executable_p "$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 cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $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 as_fn_executable_p "$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 + +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 <stdio.h> +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 <stdarg.h> +#include <stdio.h> +struct stat; +/* 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 + +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 whether $CC understands -c and -o together" >&5 +$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } +if ${am_cv_prog_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. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +$as_echo "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != 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 +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='\' + am__nodep='_no' +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". + rm -rf conftest.dir + 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 10 /bin/sh. + echo '/* dummy */' > 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 + ;; + msvc7 | msvc7msys | 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 + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC-cc} accepts -fPIE" >&5 +$as_echo_n "checking whether ${CC-cc} accepts -fPIE... " >&6; } +if ${neard_cv_prog_cc_pie+:} false; then : + $as_echo_n "(cached) " >&6 +else + + echo 'void f(){}' > conftest.c + if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then + neard_cv_prog_cc_pie=yes + else + neard_cv_prog_cc_pie=no + fi + rm -rf conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $neard_cv_prog_cc_pie" >&5 +$as_echo "$neard_cv_prog_cc_pie" >&6; } + + + + + + + +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.2' +macro_revision='1.3337' + + + + + + + + + + + + + +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" + as_fn_executable_p "$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" + as_fn_executable_p "$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" + as_fn_executable_p "$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" + as_fn_executable_p "$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 </dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break + ;; + *) + test "$with_gnu_ld" != yes && break + ;; + esac + fi + done + IFS="$lt_save_ifs" +else + lt_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$lt_cv_path_LD" +if test -n "$LD"; then + { $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 ${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 </dev/null` in +*GNU* | *'with BFD'*) + lt_cv_prog_gnu_ld=yes + ;; +*) + lt_cv_prog_gnu_ld=no + ;; +esac +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&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 as_fn_executable_p "$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 as_fn_executable_p "$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 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + 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" && \ + test undefined != "$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"`env 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 as_fn_executable_p "$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 as_fn_executable_p "$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 + ;; + +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 glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | 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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_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};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /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*|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*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*) + 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" + ;; + powerpcle-*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*) + 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 + ;; +*-*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*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; + *) + 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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 as_fn_executable_p "$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 there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&5 + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 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 -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&5 + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; 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 <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> 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 <limits.h> +#else +# include <assert.h> +#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 <ac_nonexistent.h> +_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 <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> 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 <limits.h> +#else +# include <assert.h> +#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 <ac_nonexistent.h> +_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 <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +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 <string.h> + +_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 <stdlib.h> + +_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 <ctype.h> +#include <stdlib.h> +#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; lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +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 ' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi + ;; + 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 | 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\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) + # 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\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + 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_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 <jrb3@best.com> 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='${wl}-rpath ${wl}$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 + exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + 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 + ;; + + # 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_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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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<name>.so + # instead of lib<name>.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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 + ;; + +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[23].*) 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 + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 <dlfcn.h> +#endif + +#include <stdio.h> + +#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 <dlfcn.h> +#endif + +#include <stdio.h> + +#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: + + + + if test "${enable_readline}" = "yes"; then + READLINE_TRUE= + READLINE_FALSE='#' +else + READLINE_TRUE='#' + READLINE_FALSE= +fi + + +# Check whether --enable-systemd was given. +if test "${enable_systemd+set}" = set; then : + enableval=$enable_systemd; enable_systemd=${enableval} +fi + + if test "${enable_systemd}" != "no"; then + SYSTEMD_TRUE= + SYSTEMD_FALSE='#' +else + SYSTEMD_TRUE='#' + SYSTEMD_FALSE= +fi + + + +# Check whether --with-systemdsystemunitdir was given. +if test "${with_systemdsystemunitdir+set}" = set; then : + withval=$with_systemdsystemunitdir; path_systemunitdir=${withval} +fi + +if (test "${enable_systemd}" != "no" && test -z "${path_systemunitdir}"); then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking systemd system unit dir" >&5 +$as_echo_n "checking systemd system unit dir... " >&6; } + path_systemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" + if (test -z "${path_systemunitdir}"); then + as_fn_error $? "systemd system unit directory is required" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${path_systemunitdir}" >&5 +$as_echo "${path_systemunitdir}" >&6; } +fi +SYSTEMD_SYSTEMUNITDIR=${path_systemunitdir} + + + +# Check whether --with-systemduserunitdir was given. +if test "${with_systemduserunitdir+set}" = set; then : + withval=$with_systemduserunitdir; path_userunitdir=${withval} +fi + +if (test "${enable_systemd}" != "no" && test -z "${path_userunitdir}"); then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking systemd user unit dir" >&5 +$as_echo_n "checking systemd user unit dir... " >&6; } + path_userunitdir="`$PKG_CONFIG --variable=systemduserunitdir systemd`" + if (test -z "${path_userunitdir}"); then + as_fn_error $? "systemd user unit directory is required" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${path_userunitdir}" >&5 +$as_echo "${path_userunitdir}" >&6; } +fi +SYSTEMD_USERUNITDIR=${path_userunitdir} + + +# Check whether --enable-optimization was given. +if test "${enable_optimization+set}" = set; then : + enableval=$enable_optimization; + if (test "${enableval}" = "no"); then + CFLAGS="$CFLAGS -O0" + fi + +fi + + +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; + if (test "${enableval}" = "yes" && + test "${ac_cv_prog_cc_g}" = "yes"); then + CFLAGS="$CFLAGS -g" + fi + +fi + + +# Check whether --enable-pie was given. +if test "${enable_pie+set}" = set; then : + enableval=$enable_pie; + if (test "${enableval}" = "yes" && + test "${ac_cv_prog_cc_pie}" = "yes"); then + CFLAGS="$CFLAGS -fPIE" + LDFLAGS="$LDFLAGS -pie" + fi + +fi + + +{ $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 : + dummy=yes +else + as_fn_error $? "dynamic linking loader is required" "$LINENO" 5 +fi + + +GLIB_DEPS="glib-2.0 >= 2.28" + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLIB" >&5 +$as_echo_n "checking for GLIB... " >&6; } + +if test -n "$GLIB_CFLAGS"; then + pkg_cv_GLIB_CFLAGS="$GLIB_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${GLIB_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${GLIB_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GLIB_CFLAGS=`$PKG_CONFIG --cflags "${GLIB_DEPS}" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$GLIB_LIBS"; then + pkg_cv_GLIB_LIBS="$GLIB_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${GLIB_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${GLIB_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GLIB_LIBS=`$PKG_CONFIG --libs "${GLIB_DEPS}" 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 + GLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "${GLIB_DEPS}" 2>&1` + else + GLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "${GLIB_DEPS}" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$GLIB_PKG_ERRORS" >&5 + + as_fn_error $? "GLib >= 2.28 is required" "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "GLib >= 2.28 is required" "$LINENO" 5 +else + GLIB_CFLAGS=$pkg_cv_GLIB_CFLAGS + GLIB_LIBS=$pkg_cv_GLIB_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + dummy=yes +fi + + + + +DBUS_DEPS="dbus-1 >= 1.2" + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DBUS" >&5 +$as_echo_n "checking for DBUS... " >&6; } + +if test -n "$DBUS_CFLAGS"; then + pkg_cv_DBUS_CFLAGS="$DBUS_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${DBUS_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${DBUS_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DBUS_CFLAGS=`$PKG_CONFIG --cflags "${DBUS_DEPS}" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$DBUS_LIBS"; then + pkg_cv_DBUS_LIBS="$DBUS_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${DBUS_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${DBUS_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DBUS_LIBS=`$PKG_CONFIG --libs "${DBUS_DEPS}" 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 + DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "${DBUS_DEPS}" 2>&1` + else + DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "${DBUS_DEPS}" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$DBUS_PKG_ERRORS" >&5 + + as_fn_error $? "D-Bus >= 1.2 is required" "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "D-Bus >= 1.2 is required" "$LINENO" 5 +else + DBUS_CFLAGS=$pkg_cv_DBUS_CFLAGS + DBUS_LIBS=$pkg_cv_DBUS_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + dummy=yes +fi + + + + +LIBNL3_DEPS="libnl-3.0 libnl-genl-3.0" + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNL3" >&5 +$as_echo_n "checking for LIBNL3... " >&6; } + +if test -n "$LIBNL3_CFLAGS"; then + pkg_cv_LIBNL3_CFLAGS="$LIBNL3_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL3_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL3_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL3_CFLAGS=`$PKG_CONFIG --cflags "${LIBNL3_DEPS}" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBNL3_LIBS"; then + pkg_cv_LIBNL3_LIBS="$LIBNL3_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL3_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL3_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL3_LIBS=`$PKG_CONFIG --libs "${LIBNL3_DEPS}" 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 + LIBNL3_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "${LIBNL3_DEPS}" 2>&1` + else + LIBNL3_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "${LIBNL3_DEPS}" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNL3_PKG_ERRORS" >&5 + + + LIBNL2_DEPS="libnl-2.0" + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNL2" >&5 +$as_echo_n "checking for LIBNL2... " >&6; } + +if test -n "$LIBNL2_CFLAGS"; then + pkg_cv_LIBNL2_CFLAGS="$LIBNL2_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL2_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL2_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL2_CFLAGS=`$PKG_CONFIG --cflags "${LIBNL2_DEPS}" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBNL2_LIBS"; then + pkg_cv_LIBNL2_LIBS="$LIBNL2_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL2_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL2_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL2_LIBS=`$PKG_CONFIG --libs "${LIBNL2_DEPS}" 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 + LIBNL2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "${LIBNL2_DEPS}" 2>&1` + else + LIBNL2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "${LIBNL2_DEPS}" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNL2_PKG_ERRORS" >&5 + + + LIBNL1_DEPS="libnl-1" + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNL1" >&5 +$as_echo_n "checking for LIBNL1... " >&6; } + +if test -n "$LIBNL1_CFLAGS"; then + pkg_cv_LIBNL1_CFLAGS="$LIBNL1_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL1_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL1_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL1_CFLAGS=`$PKG_CONFIG --cflags "${LIBNL1_DEPS}" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBNL1_LIBS"; then + pkg_cv_LIBNL1_LIBS="$LIBNL1_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL1_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL1_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL1_LIBS=`$PKG_CONFIG --libs "${LIBNL1_DEPS}" 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 + LIBNL1_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "${LIBNL1_DEPS}" 2>&1` + else + LIBNL1_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "${LIBNL1_DEPS}" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNL1_PKG_ERRORS" >&5 + + as_fn_error $? "Netlink library is required" "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "Netlink library is required" "$LINENO" 5 +else + LIBNL1_CFLAGS=$pkg_cv_LIBNL1_CFLAGS + LIBNL1_LIBS=$pkg_cv_LIBNL1_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + dummy=yes +fi + +$as_echo "#define NEED_LIBNL_COMPAT 1" >>confdefs.h + + NETLINK_CFLAGS=${LIBNL1_CFLAGS} + NETLINK_LIBS=${LIBNL1_LIBS} + NETLINK_DEPS=${LIBNL1_DEPS} + +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + LIBNL1_DEPS="libnl-1" + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNL1" >&5 +$as_echo_n "checking for LIBNL1... " >&6; } + +if test -n "$LIBNL1_CFLAGS"; then + pkg_cv_LIBNL1_CFLAGS="$LIBNL1_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL1_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL1_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL1_CFLAGS=`$PKG_CONFIG --cflags "${LIBNL1_DEPS}" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBNL1_LIBS"; then + pkg_cv_LIBNL1_LIBS="$LIBNL1_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL1_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL1_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL1_LIBS=`$PKG_CONFIG --libs "${LIBNL1_DEPS}" 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 + LIBNL1_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "${LIBNL1_DEPS}" 2>&1` + else + LIBNL1_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "${LIBNL1_DEPS}" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNL1_PKG_ERRORS" >&5 + + as_fn_error $? "Netlink library is required" "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "Netlink library is required" "$LINENO" 5 +else + LIBNL1_CFLAGS=$pkg_cv_LIBNL1_CFLAGS + LIBNL1_LIBS=$pkg_cv_LIBNL1_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + dummy=yes +fi + +$as_echo "#define NEED_LIBNL_COMPAT 1" >>confdefs.h + + NETLINK_CFLAGS=${LIBNL1_CFLAGS} + NETLINK_LIBS=${LIBNL1_LIBS} + NETLINK_DEPS=${LIBNL1_DEPS} + +else + LIBNL2_CFLAGS=$pkg_cv_LIBNL2_CFLAGS + LIBNL2_LIBS=$pkg_cv_LIBNL2_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + NETLINK_CFLAGS=${LIBNL2_CFLAGS} + NETLINK_LIBS=${LIBNL2_LIBS} + NETLINK_DEPS=${LIBNL2_DEPS} + +fi + +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + LIBNL2_DEPS="libnl-2.0" + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNL2" >&5 +$as_echo_n "checking for LIBNL2... " >&6; } + +if test -n "$LIBNL2_CFLAGS"; then + pkg_cv_LIBNL2_CFLAGS="$LIBNL2_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL2_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL2_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL2_CFLAGS=`$PKG_CONFIG --cflags "${LIBNL2_DEPS}" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBNL2_LIBS"; then + pkg_cv_LIBNL2_LIBS="$LIBNL2_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL2_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL2_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL2_LIBS=`$PKG_CONFIG --libs "${LIBNL2_DEPS}" 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 + LIBNL2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "${LIBNL2_DEPS}" 2>&1` + else + LIBNL2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "${LIBNL2_DEPS}" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNL2_PKG_ERRORS" >&5 + + + LIBNL1_DEPS="libnl-1" + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNL1" >&5 +$as_echo_n "checking for LIBNL1... " >&6; } + +if test -n "$LIBNL1_CFLAGS"; then + pkg_cv_LIBNL1_CFLAGS="$LIBNL1_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL1_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL1_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL1_CFLAGS=`$PKG_CONFIG --cflags "${LIBNL1_DEPS}" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBNL1_LIBS"; then + pkg_cv_LIBNL1_LIBS="$LIBNL1_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL1_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL1_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL1_LIBS=`$PKG_CONFIG --libs "${LIBNL1_DEPS}" 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 + LIBNL1_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "${LIBNL1_DEPS}" 2>&1` + else + LIBNL1_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "${LIBNL1_DEPS}" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNL1_PKG_ERRORS" >&5 + + as_fn_error $? "Netlink library is required" "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "Netlink library is required" "$LINENO" 5 +else + LIBNL1_CFLAGS=$pkg_cv_LIBNL1_CFLAGS + LIBNL1_LIBS=$pkg_cv_LIBNL1_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + dummy=yes +fi + +$as_echo "#define NEED_LIBNL_COMPAT 1" >>confdefs.h + + NETLINK_CFLAGS=${LIBNL1_CFLAGS} + NETLINK_LIBS=${LIBNL1_LIBS} + NETLINK_DEPS=${LIBNL1_DEPS} + +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + LIBNL1_DEPS="libnl-1" + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNL1" >&5 +$as_echo_n "checking for LIBNL1... " >&6; } + +if test -n "$LIBNL1_CFLAGS"; then + pkg_cv_LIBNL1_CFLAGS="$LIBNL1_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL1_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL1_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL1_CFLAGS=`$PKG_CONFIG --cflags "${LIBNL1_DEPS}" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBNL1_LIBS"; then + pkg_cv_LIBNL1_LIBS="$LIBNL1_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\${LIBNL1_DEPS}\""; } >&5 + ($PKG_CONFIG --exists --print-errors "${LIBNL1_DEPS}") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL1_LIBS=`$PKG_CONFIG --libs "${LIBNL1_DEPS}" 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 + LIBNL1_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "${LIBNL1_DEPS}" 2>&1` + else + LIBNL1_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "${LIBNL1_DEPS}" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNL1_PKG_ERRORS" >&5 + + as_fn_error $? "Netlink library is required" "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "Netlink library is required" "$LINENO" 5 +else + LIBNL1_CFLAGS=$pkg_cv_LIBNL1_CFLAGS + LIBNL1_LIBS=$pkg_cv_LIBNL1_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + dummy=yes +fi + +$as_echo "#define NEED_LIBNL_COMPAT 1" >>confdefs.h + + NETLINK_CFLAGS=${LIBNL1_CFLAGS} + NETLINK_LIBS=${LIBNL1_LIBS} + NETLINK_DEPS=${LIBNL1_DEPS} + +else + LIBNL2_CFLAGS=$pkg_cv_LIBNL2_CFLAGS + LIBNL2_LIBS=$pkg_cv_LIBNL2_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + NETLINK_CFLAGS=${LIBNL2_CFLAGS} + NETLINK_LIBS=${LIBNL2_LIBS} + NETLINK_DEPS=${LIBNL2_DEPS} + +fi + +else + LIBNL3_CFLAGS=$pkg_cv_LIBNL3_CFLAGS + LIBNL3_LIBS=$pkg_cv_LIBNL3_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + NETLINK_CFLAGS=${LIBNL3_CFLAGS} + NETLINK_LIBS=${LIBNL3_LIBS} + NETLINK_DEPS=${LIBNL3_DEPS} + +fi + + + + +# Check whether --enable-test was given. +if test "${enable_test+set}" = set; then : + enableval=$enable_test; enable_test=${enableval} +fi + + if test "${enable_test}" = "yes"; then + TEST_TRUE= + TEST_FALSE='#' +else + TEST_TRUE='#' + TEST_FALSE= +fi + + +# Check whether --enable-tools was given. +if test "${enable_tools+set}" = set; then : + enableval=$enable_tools; enable_tools=${enableval} +fi + + if test "${enable_tools}" = "yes"; then + TOOLS_TRUE= + TOOLS_FALSE='#' +else + TOOLS_TRUE='#' + TOOLS_FALSE= +fi + + +# Check whether --enable-nfctype1 was given. +if test "${enable_nfctype1+set}" = set; then : + enableval=$enable_nfctype1; enable_nfctype1=${enableval} +fi + + if test "${enable_nfctype1}" != "no"; then + NFCTYPE1_TRUE= + NFCTYPE1_FALSE='#' +else + NFCTYPE1_TRUE='#' + NFCTYPE1_FALSE= +fi + + +# Check whether --enable-nfctype2 was given. +if test "${enable_nfctype2+set}" = set; then : + enableval=$enable_nfctype2; enable_nfctype2=${enableval} +fi + + if test "${enable_nfctype2}" != "no"; then + NFCTYPE2_TRUE= + NFCTYPE2_FALSE='#' +else + NFCTYPE2_TRUE='#' + NFCTYPE2_FALSE= +fi + + +# Check whether --enable-nfctype3 was given. +if test "${enable_nfctype3+set}" = set; then : + enableval=$enable_nfctype3; enable_nfctype3=${enableval} +fi + + if test "${enable_nfctype3}" != "no"; then + NFCTYPE3_TRUE= + NFCTYPE3_FALSE='#' +else + NFCTYPE3_TRUE='#' + NFCTYPE3_FALSE= +fi + + +# Check whether --enable-nfctype4 was given. +if test "${enable_nfctype4+set}" = set; then : + enableval=$enable_nfctype4; enable_nfctype4=${enableval} +fi + + if test "${enable_nfctype4}" != "no"; then + NFCTYPE4_TRUE= + NFCTYPE4_FALSE='#' +else + NFCTYPE4_TRUE='#' + NFCTYPE4_FALSE= +fi + + +# Check whether --enable-nfctype5 was given. +if test "${enable_nfctype5+set}" = set; then : + enableval=$enable_nfctype5; enable_nfctype5=${enableval} +fi + + if test "${enable_nfctype5}" != "no"; then + NFCTYPE5_TRUE= + NFCTYPE5_FALSE='#' +else + NFCTYPE5_TRUE='#' + NFCTYPE5_FALSE= +fi + + +# Check whether --enable-p2p was given. +if test "${enable_p2p+set}" = set; then : + enableval=$enable_p2p; enable_p2p=${enableval} +fi + + if test "${enable_p2p}" != "no"; then + P2P_TRUE= + P2P_FALSE='#' +else + P2P_TRUE='#' + P2P_FALSE= +fi + + +# Check whether --enable-ese was given. +if test "${enable_ese+set}" = set; then : + enableval=$enable_ese; enable_ese=${enableval} +fi + + if test "${enable_ese}" = "yes"; then + ESE_TRUE= + ESE_FALSE='#' +else + ESE_TRUE='#' + ESE_FALSE= +fi + + + if test "${enable_ese}" = "yes"; then + SE_TRUE= + SE_FALSE='#' +else + SE_TRUE='#' + SE_FALSE= +fi + + +ac_config_files="$ac_config_files Makefile include/version.h neard.pc" + +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 + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +$as_echo_n "checking that generated files are newer than configure... " >&6; } + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 +$as_echo "done" >&6; } + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +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 "${READLINE_TRUE}" && test -z "${READLINE_FALSE}"; then + as_fn_error $? "conditional \"READLINE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${SYSTEMD_TRUE}" && test -z "${SYSTEMD_FALSE}"; then + as_fn_error $? "conditional \"SYSTEMD\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${TEST_TRUE}" && test -z "${TEST_FALSE}"; then + as_fn_error $? "conditional \"TEST\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${TOOLS_TRUE}" && test -z "${TOOLS_FALSE}"; then + as_fn_error $? "conditional \"TOOLS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${NFCTYPE1_TRUE}" && test -z "${NFCTYPE1_FALSE}"; then + as_fn_error $? "conditional \"NFCTYPE1\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${NFCTYPE2_TRUE}" && test -z "${NFCTYPE2_FALSE}"; then + as_fn_error $? "conditional \"NFCTYPE2\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${NFCTYPE3_TRUE}" && test -z "${NFCTYPE3_FALSE}"; then + as_fn_error $? "conditional \"NFCTYPE3\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${NFCTYPE4_TRUE}" && test -z "${NFCTYPE4_FALSE}"; then + as_fn_error $? "conditional \"NFCTYPE4\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${NFCTYPE5_TRUE}" && test -z "${NFCTYPE5_FALSE}"; then + as_fn_error $? "conditional \"NFCTYPE5\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${P2P_TRUE}" && test -z "${P2P_FALSE}"; then + as_fn_error $? "conditional \"P2P\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ESE_TRUE}" && test -z "${ESE_FALSE}"; then + as_fn_error $? "conditional \"ESE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${SE_TRUE}" && test -z "${SE_FALSE}"; then + as_fn_error $? "conditional \"SE\" 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 -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +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 + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# 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 neard $as_me 0.15, which was +generated by GNU Autoconf 2.69. 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 <linux-nfc@lists.01.org>." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +neard config.status 0.15 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 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"`' +PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $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_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 \ +PATH_SEPARATOR \ +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_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" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "include/version.h") CONFIG_FILES="$CONFIG_FILES include/version.h" ;; + "neard.pc") CONFIG_FILES="$CONFIG_FILES neard.pc" ;; + + *) 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 2>/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 +' <conf$$subs.awk | sed ' +/^[^""]/{ + N + s/\n// +} +' >>$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 +' <confdefs.h | sed ' +s/'"$ac_delim"'/"\\\ +"/g' >>$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"" || { + # Older Autoconf 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"` + # 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'`; 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, 2011 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 PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + +# 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 + +# 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 +
diff --git a/neard/configure.ac b/neard/configure.ac new file mode 100644 index 0000000..e722e9a --- /dev/null +++ b/neard/configure.ac
@@ -0,0 +1,188 @@ +AC_PREREQ(2.60) +AC_INIT(neard, 0.15, [linux-nfc@lists.01.org]) +AC_CONFIG_MACRO_DIR([m4]) + +AM_INIT_AUTOMAKE([foreign subdir-objects color-tests]) +AC_CONFIG_HEADERS(config.h) + +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +AM_MAINTAINER_MODE + +# Do not expand the default variables so that they can be changed at build +# time, in the make command-line. +if (test "${libdir}" = '${exec_prefix}/lib'); then + libdir='${prefix}/lib' +fi + +plugindir='${pkglibdir}/plugins' +se_plugindir='${pkglibdir}/plugins-se' +AC_SUBST(plugindir) +AC_SUBST(se_plugindir) + +PKG_PROG_PKG_CONFIG + +NEARD_COMPILER_FLAGS + +AC_LANG([C]) + +AC_PROG_CC +NEARD_PROG_CC_PIE +AC_PROG_INSTALL +AC_PROG_MKDIR_P + +m4_define([_LT_AC_TAGCONFIG], []) +m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])]) + +LT_INIT([disable-static]) + +AM_CONDITIONAL(READLINE, test "${enable_readline}" = "yes") + +AC_ARG_ENABLE(systemd, AS_HELP_STRING([--disable-systemd], + [disable systemd integration]), [enable_systemd=${enableval}]) +AM_CONDITIONAL(SYSTEMD, test "${enable_systemd}" != "no") + +AC_ARG_WITH([systemdsystemunitdir], + AS_HELP_STRING([--with-systemdsystemunitdir=DIR], + [path to systemd system unit directory]), + [path_systemunitdir=${withval}]) +if (test "${enable_systemd}" != "no" && test -z "${path_systemunitdir}"); then + AC_MSG_CHECKING([systemd system unit dir]) + path_systemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" + if (test -z "${path_systemunitdir}"); then + AC_MSG_ERROR([systemd system unit directory is required]) + fi + AC_MSG_RESULT([${path_systemunitdir}]) +fi +AC_SUBST(SYSTEMD_SYSTEMUNITDIR, [${path_systemunitdir}]) + +AC_ARG_WITH([systemduserunitdir], + AS_HELP_STRING([--with-systemduserunitdir=DIR], + [path to systemd user unit directory]), + [path_userunitdir=${withval}]) +if (test "${enable_systemd}" != "no" && test -z "${path_userunitdir}"); then + AC_MSG_CHECKING([systemd user unit dir]) + path_userunitdir="`$PKG_CONFIG --variable=systemduserunitdir systemd`" + if (test -z "${path_userunitdir}"); then + AC_MSG_ERROR([systemd user unit directory is required]) + fi + AC_MSG_RESULT([${path_userunitdir}]) +fi +AC_SUBST(SYSTEMD_USERUNITDIR, [${path_userunitdir}]) + +AC_ARG_ENABLE(optimization, AS_HELP_STRING([--disable-optimization], + [disable code optimization through compiler]), [ + if (test "${enableval}" = "no"); then + CFLAGS="$CFLAGS -O0" + fi +]) + +AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], + [enable compiling with debugging information]), [ + if (test "${enableval}" = "yes" && + test "${ac_cv_prog_cc_g}" = "yes"); then + CFLAGS="$CFLAGS -g" + fi +]) + +AC_ARG_ENABLE(pie, AS_HELP_STRING([--enable-pie], + [enable position independent executables flag]), [ + if (test "${enableval}" = "yes" && + test "${ac_cv_prog_cc_pie}" = "yes"); then + CFLAGS="$CFLAGS -fPIE" + LDFLAGS="$LDFLAGS -pie" + fi +]) + +AC_CHECK_LIB(dl, dlopen, dummy=yes, + AC_MSG_ERROR(dynamic linking loader is required)) + +GLIB_DEPS="glib-2.0 >= 2.28" +PKG_CHECK_MODULES(GLIB, [${GLIB_DEPS}], dummy=yes, + AC_MSG_ERROR(GLib >= 2.28 is required)) +AC_SUBST(GLIB_CFLAGS) +AC_SUBST(GLIB_LIBS) +AC_SUBST(GLIB_DEPS) + +DBUS_DEPS="dbus-1 >= 1.2" +PKG_CHECK_MODULES(DBUS, [${DBUS_DEPS}], dummy=yes, + AC_MSG_ERROR(D-Bus >= 1.2 is required)) +AC_SUBST(DBUS_CFLAGS) +AC_SUBST(DBUS_LIBS) +AC_SUBST(DBUS_DEPS) + +LIBNL3_DEPS="libnl-3.0 libnl-genl-3.0" +PKG_CHECK_MODULES(LIBNL3, [${LIBNL3_DEPS}], [ + NETLINK_CFLAGS=${LIBNL3_CFLAGS} + NETLINK_LIBS=${LIBNL3_LIBS} + NETLINK_DEPS=${LIBNL3_DEPS} +], [ + LIBNL2_DEPS="libnl-2.0" + PKG_CHECK_MODULES(LIBNL2, [${LIBNL2_DEPS}], [ + NETLINK_CFLAGS=${LIBNL2_CFLAGS} + NETLINK_LIBS=${LIBNL2_LIBS} + NETLINK_DEPS=${LIBNL2_DEPS} + ], [ + LIBNL1_DEPS="libnl-1" + PKG_CHECK_MODULES(LIBNL1, [${LIBNL1_DEPS}], dummy=yes, + AC_MSG_ERROR(Netlink library is required)) + AC_DEFINE(NEED_LIBNL_COMPAT, 1, + [Define to 1 if you need libnl-1 compat functions.]) + NETLINK_CFLAGS=${LIBNL1_CFLAGS} + NETLINK_LIBS=${LIBNL1_LIBS} + NETLINK_DEPS=${LIBNL1_DEPS} + ]) +]) +AC_SUBST(NETLINK_CFLAGS) +AC_SUBST(NETLINK_LIBS) +AC_SUBST(NETLINK_DEPS) + +AC_ARG_ENABLE(test, AS_HELP_STRING([--enable-test], + [enable test/example scripts]), + [enable_test=${enableval}]) +AM_CONDITIONAL(TEST, test "${enable_test}" = "yes") + +AC_ARG_ENABLE(tools, AS_HELP_STRING([--enable-tools], + [enable testing tools]), + [enable_tools=${enableval}]) +AM_CONDITIONAL(TOOLS, test "${enable_tools}" = "yes") + +AC_ARG_ENABLE(nfctype1, AS_HELP_STRING([--disable-nfctype1], + [disable NFC forum type 1 tags support]), + [enable_nfctype1=${enableval}]) +AM_CONDITIONAL(NFCTYPE1, test "${enable_nfctype1}" != "no") + +AC_ARG_ENABLE(nfctype2, AS_HELP_STRING([--disable-nfctype2], + [disable NFC forum type 2 tags support]), + [enable_nfctype2=${enableval}]) +AM_CONDITIONAL(NFCTYPE2, test "${enable_nfctype2}" != "no") + +AC_ARG_ENABLE(nfctype3, AS_HELP_STRING([--disable-nfctype3], + [disable NFC forum type 3 tags support]), + [enable_nfctype3=${enableval}]) +AM_CONDITIONAL(NFCTYPE3, test "${enable_nfctype3}" != "no") + +AC_ARG_ENABLE(nfctype4, AS_HELP_STRING([--disable-nfctype4], + [disable NFC forum type 4 tags support]), + [enable_nfctype4=${enableval}]) +AM_CONDITIONAL(NFCTYPE4, test "${enable_nfctype4}" != "no") + +AC_ARG_ENABLE(nfctype5, AS_HELP_STRING([--disable-nfctype5], + [disable NFC forum type 5 tags support]), + [enable_nfctype5=${enableval}]) +AM_CONDITIONAL(NFCTYPE5, test "${enable_nfctype5}" != "no") + +AC_ARG_ENABLE(p2p, AS_HELP_STRING([--disable-p2p], + [disable NFC peer to peer support]), + [enable_p2p=${enableval}]) +AM_CONDITIONAL(P2P, test "${enable_p2p}" != "no") + +AC_ARG_ENABLE(ese, AS_HELP_STRING([--enable-ese], + [enable embedded SE support]), + [enable_ese=${enableval}]) +AM_CONDITIONAL(ESE, test "${enable_ese}" = "yes") + +AM_CONDITIONAL(SE, test "${enable_ese}" = "yes") + +AC_CONFIG_FILES([Makefile include/version.h neard.pc]) +AC_OUTPUT
diff --git a/neard/depcomp b/neard/depcomp new file mode 100755 index 0000000..4ebd5b3 --- /dev/null +++ b/neard/depcomp
@@ -0,0 +1,791 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2013-05-30.07; # UTC + +# Copyright (C) 1999-2013 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 <http://www.gnu.org/licenses/>. + +# 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 <oliva@dcc.unicamp.br>. + +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 outputting dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to <bug-automake@gnu.org>. +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +# Get the directory component of the given path, and save it in the +# global variables '$dir'. Note that this directory component will +# be either empty or ending with a '/' character. This is deliberate. +set_dir_from () +{ + case $1 in + */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; + *) dir=;; + esac +} + +# Get the suffix-stripped basename of the given path, and save it the +# global variable '$base'. +set_base_from () +{ + base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` +} + +# If no dependency file was actually created by the compiler invocation, +# we still have to create a dummy depfile, to avoid errors with the +# Makefile "include basename.Plo" scheme. +make_dummy_depfile () +{ + echo "#dummy" > "$depfile" +} + +# Factor out some common post-processing of the generated depfile. +# Requires the auxiliary global variable '$tmpdepfile' to be set. +aix_post_process_depfile () +{ + # If the compiler actually managed to produce a dependency file, + # post-process it. + if test -f "$tmpdepfile"; then + # Each line is of the form 'foo.o: dependency.h'. + # Do two passes, one to just change these to + # $object: dependency.h + # and one to simply output + # dependency.h: + # which is needed to avoid the deleted-header problem. + { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" + sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" + } > "$depfile" + rm -f "$tmpdepfile" + else + make_dummy_depfile + fi +} + +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' +# Character ranges might be problematic outside the C locale. +# These definitions help. +upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ +lower=abcdefghijklmnopqrstuvwxyz +digits=0123456789 +alpha=${upper}${lower} + +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" + +# Avoid interferences from the environment. +gccflag= dashmflag= + +# 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 + +if test "$depmode" = msvc7msys; then + # This is just like msvc7 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=msvc7 +fi + +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. + gccflag=-qmakedep=gcc,-MF + depmode=gcc +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 -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## (see the conditional assignment to $gccflag above). +## 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). Also, it might not be +## supported by the other compilers which use the 'gcc' depmode. +## - 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 -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # 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. +## 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. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -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 -ne 0; then + 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 ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ + | tr "$nl" ' ' >> "$depfile" + echo >> "$depfile" + # The second pass generates a dummy entry for each header file. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" + ;; + +xlc) + # 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 + ;; + +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. + set_dir_from "$object" + set_base_from "$object" + 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 -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + aix_post_process_depfile + ;; + +tcc) + # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 + # FIXME: That version still under development at the moment of writing. + # Make that this statement remains true also for stable, released + # versions. + # It will wrap lines (doesn't matter whether long or short) with a + # trailing '\', as in: + # + # foo.o : \ + # foo.c \ + # foo.h \ + # + # It will put a trailing '\' even on the last line, and will use leading + # spaces rather than leading tabs (at least since its commit 0394caf7 + # "Emit spaces for -MD"). + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. + # We have to change lines of the first kind to '$object: \'. + sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" + # And for each line of the second kind, we have to emit a 'dep.h:' + # dummy dependency, to avoid the deleted-header problem. + sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +## The order of this option in the case statement is important, since the +## shell code in configure will try each of these formats in the order +## listed in this file. A plain '-MD' option would be understood by many +## compilers, so we must ensure this comes after the gcc and icc options. +pgcc) + # Portland's C compiler understands '-MD'. + # Will always output deps to 'file.d' where file is the root name of the + # source file under compilation, even if file resides in a subdirectory. + # The object file name does not affect the name of the '.d' file. + # pgcc 10.2 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using '\' : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + set_dir_from "$object" + # Use the source, not the object, to determine the base name, since + # that's sadly what pgcc will do too. + set_base_from "$source" + tmpdepfile=$base.d + + # For projects that build the same source file twice into different object + # files, the pgcc approach of using the *source* file root name can cause + # problems in parallel builds. Use a locking strategy to avoid stomping on + # the same $tmpdepfile. + lockdir=$base.d-lock + trap " + echo '$0: caught signal, cleaning up...' >&2 + rmdir '$lockdir' + exit 1 + " 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0; do + # mkdir is a portable test-and-set. + if mkdir "$lockdir" 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rmdir "$lockdir" + break + else + # If the lock is being held by a different process, wait + # until the winning process is done or we timeout. + while test -d "$lockdir" && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi + + if test $stat -ne 0; then + 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. + set_dir_from "$object" + set_base_from "$object" + 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 -ne 0; then + 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,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" + # Add 'dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + make_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. + set_dir_from "$object" + set_base_from "$object" + + if test "$libtool" = yes; then + # Libtool 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$base.o.d # libtool 1.5 + tmpdepfile2=$dir.libs/$base.o.d # Likewise. + tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + # Same post-processing that is required for AIX mode. + aix_post_process_depfile + ;; + +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/'"$tab"'\1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/'"$tab"'/ + G + p +}' >> "$depfile" + echo >> "$depfile" # make sure the fragment doesn't end with a backslash + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # 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 + ;; + +#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|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this sed invocation + # correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | 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" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process the last invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed '1,2d' "$tmpdepfile" \ + | tr ' ' "$nl" \ + | 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::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$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:
diff --git a/neard/doc/adapter-api.txt b/neard/doc/adapter-api.txt new file mode 100644 index 0000000..86aa818 --- /dev/null +++ b/neard/doc/adapter-api.txt
@@ -0,0 +1,119 @@ +Adapter hierarchy +================= + +Service org.neard +Interface org.neard.Adapter +Object path [variable prefix]/{nfc0,nfc1,...} + +Methods: dict GetProperties() + + Returns all properties for the device. See the + properties section for available properties. + + Possible Errors: org.neard.Error.DoesNotExist + + void SetProperty(string name, variant value) + + Changes the value of the specified property. Only + properties that are listed a read-write are changeable. + On success this will emit a PropertyChanged signal. + + Possible Errors: org.neard.Error.DoesNotExist + org.neard.Error.InvalidArguments + + void StartPollLoop(string mode) + + Starts the adapter polling loop. Depending on the mode, + the adapter will start polling for targets, listening + for NFC devices or both. + The mode parameter can have the following values: + "Initiator", "Target" or "Dual". For any other value + the adapter will fall back to initiator mode. + Dual mode will have the adapter alternate between target + and initiator modes during the polling loop. + + This process will start emitting TagFound and + PropertyChanged "Polling" signals. + + Possible errors: org.neard.Error.NotReady + org.neard.Error.Failed + org.neard.Error.NotSupported + + void StopPollLoop() + + The adapter polling loop will stop. + + Possible errors: org.neard.Error.NotReady + org.neard.Error.Failed + org.neard.Error.NotSupported + + object StartEmulation(dict attributes) + + Starts tag emulation mode. + + Adapters can only emulate one target at a time, so + subsequent calls to this method will always return + the same object path. + + The attributes dictionary is described by the + Record properties. + For example, one would add a type, a Language, an + Encoding and a Representation for emulating a text + NDEF record. + + Returns the object path for the emulated target. + + Possible errors: org.neard.Error.NotReady + org.neard.Error.Failed + org.neard.Error.NotSupported + + void StopEmulation() + + Stops tag emulation mode. + + Possible errors: org.neard.Error.NotReady + org.neard.Error.Failed + org.neard.Error.NotSupported + + +Signals PropertyChanged(string name, variant value) + + This signal indicates a changed value of the given + property. + + TagFound(string address, dict values) + + This signal is sent whenever an NFC tag is found, + as a result of a probe response reception. + + The dictionary contains basically the same values + that are returned by the GetProperties method + from the org.neard.Tag interface. + + TagLost(string address) + + This signal is sent whenever the NFC tag is no longer + in sight, or when it's been de-activated. + + +Properties string Mode [readonly] + + The adapter NFC radio mode. + + Valid types are "Initiator", "Target" and "Idle" + + boolean Powered [readwrite] + + Switch an adapter on or off. + + boolean Polling [readonly] + + Indicates that the adapter is currently polling for + targets. This is only valid when the adapter is in + initiator mode. + + array{string} Protocols [readonly] + + The adapter supported protocols. + Possible values are "Felica", "MIFARE", "Jewel", + "ISO-DEP" and "NFC-DEP".
diff --git a/neard/doc/agent-api.txt b/neard/doc/agent-api.txt new file mode 100644 index 0000000..33c47fa --- /dev/null +++ b/neard/doc/agent-api.txt
@@ -0,0 +1,165 @@ +Agent Manager hierarchy +======================= + +Service org.neard +Interface org.neard.AgentManager +Object path /org/neard + +Methods void RegisterHandoverAgent(object path, string carrier) + + Register new handover agent. + + Supported carriers are: 'bluetooth', 'wifi'. + Only one registration will be accepted per carrier. + + Possible Errors: org.neard.Error.InvalidArguments + org.neard.Error.AlreadyExists. + + void UnregisterHandoverAgent(object path, string carrier) + + Unregister an existing handover agent. + + Possible Errors: org.neard.Error.InvalidArguments + + void RegisterNDEFAgent(object path, string type) + + Register new NDEF agent. + + When a record matching the registered type is found, + the agent will get the whole NDEF as a raw byte stream. + + Possible Errors: org.neard.Error.InvalidArguments + + void UnregisterNDEFAgent(object path, string type) + + Unregister an existing NDEF agent. + + Possible Errors: org.neard.Error.InvalidArguments + + +HandoverAgent hierarchy +======================= + +Service unique name +Interface org.neard.HandoverAgent +Object path freely definable + +Methods dict RequestOOB(dict values) [experimental] + + This method gets called when the service daemon + needs to get Out Of Band data from the handover + agent, typically the BlueZ daemon. + + The service daemon will use this OOB data to build + a Handover Request or Select message and send it to + remote device. + + Values parameter is optional. It should be a dictionary + where the keys are the field names and the values are + the actual fields. If provided it should contain remote + Out Of Band data received in Handover Request message. + Those data will be stored for future use (i.e. when + remote initialize pairing) and providing those will not + initialize pairing. + + The return value should be a dictionary where the + keys are the field names and the values are the + actual fields. + + Possible Errors: org.neard.HandoverAgent.Error.InProgress + org.neard.HandoverAgent.Error.Failed + + void PushOOB(dict values) [experimental] + + This method gets called when service daemon received + Handover Select message from selector and needs to pass + remote Out Of Band data to agent to start handover. + + If there is no Bluetooth adapter or if it doesn't + support simple pairing the agent will return an error. + + Agent shall implicitly initialize pairing if needed. + + This function returns when alternative carrier + (Bluetooth) is ready to be used i.e. pairing has + finished. + + Parameter should be a dictionary where the keys are the + field names and the values are the actual fields. + + Possible Errors: org.neard.HandoverAgent.Error.InProgress + org.neard.HandoverAgent.Error.Failed + + void Release() [experimental] + + This method gets called when the service daemon + unregisters the agent. An agent can use it to do + cleanup tasks. There is no need to unregister the + agent, because when this method gets called it has + already been unregistered. + +Fields array{byte} EIR + + This is EIR blob as described in Bluetooth Core + Specification 4.0 (Vol 3, Part C, chapter 8.1.6). + Used by SSP capable devices. + + array{byte} nokia.com:bt + + This is a proprietary extension blob used by some + Nokia Bluetooth 2.0 devices. + + array{byte} WSC + + This is a WiFi blob as described in WiFi Simple + Configuration Technical Specification v2.0.2.1-rev4. + (Annex L - Data Element Definitions) + + string State + + Carrier power state. This is a hint for handover agent + about power state of carrier on remote device. Agent + should also use it to inform neard about power state + of its own carrier (in RequestOOB reply). It is up to + agent to decide how to use this information. + + This field may be present only if nokia.com:bt or + EIR field is also present. + + Possible values are "active", "inactive", "activating". + + +NDEFAgent hierarchy +======================= + +Service unique name +Interface org.neard.NDEFAgent +Object path freely definable + +Methods void GetNDEF(dict values) [experimental] + + This method gets called when the service daemon + found an NDEF matching the registered type. + + The parameter is a dictionary where the keys are the + field names and the values are the actual fields. + + void Release() [experimental] + + This method gets called when the service daemon + unregisters the agent. An agent can use it to do + cleanup tasks. There is no need to unregister the + agent, because when this method gets called it has + already been unregistered. + +Fields array{byte} NDEF + + This is the raw NDEF data. + + array{byte} Payload + + This is the NDEF record payload. + + object Record + + This is a record object path.
diff --git a/neard/doc/coding-style.txt b/neard/doc/coding-style.txt new file mode 100644 index 0000000..75ba3c4 --- /dev/null +++ b/neard/doc/coding-style.txt
@@ -0,0 +1,344 @@ +ï»żEvery project has its coding style, and neard is not an exception. This +document describes the preferred coding style for neard code, in order to keep +some level of consistency among developers so that code can be easily +understood and maintained, and also to help your code survive under +maintainer's fastidious eyes so that you can get a passport for your patch +ASAP. + +First of all, neard coding style must follow every rule for Linux kernel +(http://www.kernel.org/doc/Documentation/CodingStyle). There also exists a tool +named checkpatch.pl to help you check the compliance with it. Just type +"checkpatch.pl --no-tree patch_name" to check your patch. In theory, you need +to clean up all the warnings and errors except this one: "ERROR: Missing +Signed-off-by: line(s)". neard does not used Signed-Off lines, so including +them is actually an error. In certain circumstances one can ignore the 80 +character per line limit. This is generally only allowed if the alternative +would make the code even less readable. + +Besides the kernel coding style above, neard has special flavors for its own. +Some of them are mandatory (marked as 'M'), while some others are optional +(marked as 'O'), but generally preferred. + +M1: Blank line before and after an if/while/do/for statement +============================================================ +There should be a blank line before if statement unless the if is nested and +not preceded by an expression or variable declaration. + +Example: +1) +a = 1; +if (b) { // wrong + +2) +a = 1 + +if (b) { +} +a = 2; // wrong + +3) +if (a) { + if (b) // correct + +4) +b = 2; + +if (a) { // correct + +} + +b = 3; + +The only exception to this rule applies when a variable is being allocated: +array = g_try_new0(int, 20); +if (array) // Correct + return; + + +M2: Multiple line comment +========================= +If your comments have more then one line, please start it from the second line. + +Example: +/* + * first line comment // correct + * ... + * last line comment + */ + + +M3: Space before and after operator +=================================== +There should be a space before and after each operator. + +Example: +a + b; // correct + + +M4: Wrap long lines +=================== +If your condition in if, while, for statement or a function declaration is too +long to fit in one line, the new line needs to be indented not aligned with the +body. + +Example: +1) +if (call->status == CALL_STATUS_ACTIVE || + call->status == CALL_STATUS_HELD) { // wrong + neard_dbus_dict_append(); + +2) +if (call->status == CALL_STATUS_ACTIVE || + call->status == CALL_STATUS_HELD) { // correct + neard_dbus_dict_append(); + +3) +gboolean sim_ust_is_available(unsigned char *service_ust, unsigned char len, + num sim_ust_service index) // wrong +{ + int a; + ... +} + +4) +gboolean sim_ust_is_available(unsigned char *service_ust, unsigned char len, + enum sim_ust_service index) // correct +{ + int a; + ... +} + +If the line being wrapped is a function call or function declaration, the +preferred style is to indent at least past the opening parenthesis. Indenting +further is acceptable as well (as long as you don't hit the 80 character +limit). + +If this is not possible due to hitting the 80 character limit, then indenting +as far as possible to the right without hitting the limit is preferred. + +Example: + +1) +gboolean sim_ust_is_available(unsigned char *service_ust, unsigned char len, + enum sim_ust_service index); // worse + +2) +gboolean sim_ust_is_available(unsigned char *service_ust, unsigned char len, + enum sim_ust_service index); + // better + +M5: Git commit message 50/72 formatting +======================================= +The commit message header should be within 50 characters. And if you have +detailed explanatory text, wrap it to 72 character. + + +M6: Space when doing type casting +================================= +There should be a space between new type and variable. + +Example: +1) +a = (int *)b; // wrong +2) +a = (int *) b; // correct + + +M7: Don't initialize variable unnecessarily +=========================================== +When declaring a variable, try not to initialize it unless necessary. + +Example: +int i = 1; // wrong + +for (i = 0; i < 3; i++) { +} + + +M8: Use g_try_malloc instead of g_malloc +======================================== +When g_malloc fails, the whole program would exit. Most of time, this is not +the expected behavior, and you may want to use g_try_malloc instead. + +Example: +additional = g_try_malloc(len - 1); // correct +if (additional) + return FALSE; + + +M9: Follow the order of include header elements +=============================================== +When writing an include header the various elements should be in the following +order: + - #includes + - forward declarations + - #defines + - enums + - typedefs + - function declarations and inline function definitions + + +M10: Internal headers must not use include guards +================================================= +Any time when creating a new header file with non-public API, that header +must not contain include guards. + + +M11: Naming of enums +==================== + +Enums must have a descriptive name. The enum type should be small caps and +it should not be typedef-ed. Enum contents should be in CAPITAL letters and +prefixed by the enum type name. + +Example: + +enum animal_type { + ANIMAL_TYPE_FOUR_LEGS, + ANIMAL_TYPE_EIGHT_LEGS, + ANIMAL_TYPE_TWO_LEGS, +}; + +If the enum contents have values (e.g. from specification) the formatting +should be as follows: + +enum animal_type { + ANIMAL_TYPE_FOUR_LEGS = 4, + ANIMAL_TYPE_EIGHT_LEGS = 8, + ANIMAL_TYPE_TWO_LEGS = 2, +}; + +M12: Enum as switch variable +==================== + +If the variable of a switch is an enum, you must not include a default in +switch body. The reason for this is: If later on you modify the enum by adding +a new type, and forget to change the switch accordingly, the compiler will +complain the new added type hasn't been handled. + +Example: + +enum animal_type { + ANIMAL_TYPE_FOUR_LEGS = 4, + ANIMAL_TYPE_EIGHT_LEGS = 8, + ANIMAL_TYPE_TWO_LEGS = 2, +}; + +enum animal_type t; + +switch (t) { +case ANIMAL_TYPE_FOUR_LEGS: + ... + break; +case ANIMAL_TYPE_EIGHT_LEGS: + ... + break; +case ANIMAL_TYPE_TWO_LEGS: + ... + break; +default: // wrong + break; +} + +However if the enum comes from an external header file outside neard +we cannot make any assumption of how the enum is defined and this +rule might not apply. + +M13: Check for pointer being NULL +================================= + +When checking if a pointer or a return value is NULL, use the +check with "!" operator. + +Example: +1) +array = g_try_new0(int, 20); +if (!array) // Correct + return; + +2) +if (!g_at_chat_get_slave(chat)) // Correct + return -EINVAL; + +3) +array = g_try_new0(int, 20); +if (array == NULL) // Wrong + return; + + +M14: Always use parenthesis with sizeof +======================================= +The expression argument to the sizeof operator should always be in +parenthesis, too. + +Example: +1) +memset(stuff, 0, sizeof(*stuff)); + +2) +memset(stuff, 0, sizeof *stuff); // Wrong + + +M15: Use void if function has no parameters +=========================================================== +A function with no parameters must use void in the parameter list. + +Example: +1) +void foo(void) +{ +} + +2) +void foo() // Wrong +{ +} + +M16: Don't use hex value with shift operators +============================================== +The expression argument to the shift operators should not be in hex. + +Example: + +1) +1 << y + +2) +0x1 << y // Wrong + +O1: Shorten the name +==================== +Better to use abbreviation, rather than full name, to name a variable, +function, struct, etc. + +Example: +supplementary_service // too long +ss // better + +O2: Try to avoid complex if body +================================ +It's better not to have a complicated statement for if. You may judge its +contrary condition and return | break | continue | goto ASAP. + +Example: +1) +if (a) { // worse + struct voicecall *v; + call = synthesize_outgoing_call(vc, vc->pending); + v = voicecall_create(vc, call); + v->detect_time = time(NULL); + DBG("Registering new call: %d", call->id); + voicecall_dbus_register(v); +} else + return; + +2) +if (!a) + return; + +struct voicecall *v; +call = synthesize_outgoing_call(vc, vc->pending); +v = voicecall_create(vc, call); +v->detect_time = time(NULL); +DBG("Registering new call: %d", call->id); +voicecall_dbus_register(v);
diff --git a/neard/doc/device-api.txt b/neard/doc/device-api.txt new file mode 100644 index 0000000..94efcfa --- /dev/null +++ b/neard/doc/device-api.txt
@@ -0,0 +1,38 @@ +Device hierarchy +================ + +Service org.neard +Interface org.neard.Device +Object path [variable prefix]/{nfc0}/{device0, device1...} + +Method void Push(dict attributes) + + Creates an NDEF record from the attributes dictionary. + + The attributes argument should at least contain a + record type. The rest of the attributes dictionary + depends on the record type: + + ----------------------------------------------------- + | Type | Additional dictionary keys | + ----------------------------------------------------- + | Text | Encoding, Language, Representation | + ----------------------------------------------------- + | URI | URI | + ----------------------------------------------------- + | SmartPoster | URI | + ----------------------------------------------------- + | Handover | Carrier (wifi or/and bluetooth) | + ----------------------------------------------------- + | StaticHandover | Carrier (wifi or/and bluetooth) | + ----------------------------------------------------- + | MIME | MIME, Payload (optional) | + ----------------------------------------------------- + + Possible Errors: org.neard.Error.PermissionDenied + org.neard.Error.InvalidArguments + org.neard.Error.InProgress + +Properties object Adapter [readonly] + + The object path of the adapter the device belongs to.
diff --git a/neard/doc/features.txt b/neard/doc/features.txt new file mode 100644 index 0000000..6084e3a --- /dev/null +++ b/neard/doc/features.txt
@@ -0,0 +1,47 @@ +neard - Near Field Communication daemon +======================================= + +Purpose +======= + +This document describes all the major functionalities +supported by neard. + + +Reader Mode +=========== +Supported tags: + + * Type 1: Supported. + * Type 2: Supported. + * MIFARE classic 1K and 4K supported. + * Type 3: Supported. + * Type 4: Supported. + * Type 5: Supported. + + +Card Emulation Mode +=================== +Not supported. + + +Writer Mode +=========== +Supported tags: + + * Type 1: Supported. + * Type 2: Supported. + * Type 3: Supported. + * Type 4: Supported. + * Type 5: Supported. + + +Peer To Peer Mode +================= +neard reads and write NDEFs from p2p devices, through SNEP and NPP. +Both initiator and target modes are supported. + + +Handover +======== +WIP.
diff --git a/neard/doc/neard.8 b/neard/doc/neard.8 new file mode 100644 index 0000000..7139eb5 --- /dev/null +++ b/neard/doc/neard.8
@@ -0,0 +1,52 @@ +.\" neard(8) manual page +.\" +.\" Copyright (C) 2013 Intel Corporation +.\" +.TH NEARD "8" "7 March 2013" +.SH NAME +neard \- Near Field Communication daemon +.SH SYNOPSIS +.B neard [\-\-version] | [\-\-help] +.PP +.B neard [\-\-debug=<file1>:<file2>:...] [\-\-plugin=<plugin1>,<plugin2>,...] [\-\-noplugin=<plugin1>,<plugin2>,...] [\-\-nodaemon] +.SH DESCRIPTION +\fIneard\fP is an NFC (Near Field Communication) daemon for managing +NFC operations on devices running the Linux operating system. It relies +on the Linux kernel NFC socket and generic netlink families, and is a +fully modular system that can be extended through plug-ins. + +It supports all 4 NFC tag types reading and writing, along with NFC LLCP +(peer to peer mode) in both target and initiator modes. The Simple NDEF +Exchange Protocol (SNEP), NDEF Push Protocol (NPP) and handover (Wi-Fi and +Bluetooth) protocols are implemented as separate plugins on top of LLCP sockets. +.P +.SH OPTIONS +The following options are supported: +.TP +.I "\-\-version" +Print the neard software version and exit. +.TP +.I "\-\-help" +Print neard's available options and exit. +.TP +.I "\-\-debug=<file1>:<file2>:..." +Sets how much information neard sends to the log destination (usually +syslog's "daemon" facility). If the file options are omitted, then debugging +information from all the source files are printed. If file options are +present, then only debug prints from that source file are printed. +Example: --debug=src/service.c:plugins/wifi.c +.TP +.I "\-\-plugin=<plugin1>,<plugin2>,..." +Load these plugins only. The option can be a pattern containing +"*" and "?" characters. +.TP +.I "\-\-noplugin=<plugin1>,<plugin2>,..." +Never load these plugins. The option can be a pattern containing +"*" and "?" characters. +.TP +.I "\-\-nodaemon" +Do not daemonize. This is useful for debugging, and directs log output to +the controlling terminal in addition to syslog. +.TP +.SH SEE ALSO +.BR neard.conf (5).
diff --git a/neard/doc/neard.conf.5 b/neard/doc/neard.conf.5 new file mode 100644 index 0000000..2cb3ad6 --- /dev/null +++ b/neard/doc/neard.conf.5
@@ -0,0 +1,47 @@ +.\" neard.conf(5) manual page +.\" +.\" Copyright (C) 2013 Intel Corporation +.\" +.TH "neard.conf" "5" "7 March 2013" "" +.SH NAME +main.conf \- neard configuration file +.SH SYNOPSIS +/etc/neard/main.conf +.br +or +.br +\fI<SYSCONFDIR>\fP/neard/main.conf +.br +where <SYSCONFDIR> depends on your distribution or build. +.SH DESCRIPTION +.P +.I main.conf +is a configuration file for \fBneard\fP (8). The configuration file is +optional but it can be used to set up various aspects of neard's +behavior. +.SH "FILE FORMAT" +.P +The configuration file format is key file format. +It consists of sections (groups) of key-value pairs. +Lines beginning with a '#' and blank lines are considered comments. +Sections are started by a header line containing the section enclosed +in '[' and ']', and ended implicitly by the start of the next section +or the end of the file. Each key-value pair must be contained in a section. +.P +Description of sections and available keys follows: +.SS [General] +This section is the only mandatory section of the configuration file. +.TP +.B ConstantPoll=\fPtrue|false\fP +Enable constant polling. Default is false. Constant polling will force neard +into starting a new polling cycle whenever a target or a device are lost. +.TP +.B DefaultPowered=\fPtrue|false\fP +Automatically turn an adapter on when being discovered. +Default value is false. +.TP +.B ResetOnError=\fPtrue|false\fP +Power cycle the adapter when getting a driver error from the kernel. +Default value is true. +.SH "SEE ALSO" +.BR neard (8)
diff --git a/neard/doc/nfctool.1 b/neard/doc/nfctool.1 new file mode 100644 index 0000000..6b62657 --- /dev/null +++ b/neard/doc/nfctool.1
@@ -0,0 +1,168 @@ +.\" nfctool(1) manual page +.\" +.\" Copyright (C) 2013 Intel Corporation +.\" +.TH NFCTOOL 1 "February 2013" + +.SH NAME +.B nfctool +\- a NFC toolbox + +.SH SYNOPSIS +.B nfctool [OPTIONS...] + +.SH DESCRIPTION +.PP +The \fBnfctool\fR application performs various operations on NFC devices, such +as: +.IP \[bu] 2 +list connected devices +.IP \[bu] +put device in polling mode +.IP \[bu] +get and set parameters for the local LLC +.IP \[bu] +send service name lookup request to the remote LLC. +.IP \[bu] +dump LLCP link traffic + +.SH OPTIONS +.PP +\fB\-h\fR, \fB\-\-help\fR +.RS 4 +Print nfctool's available options and exit. +.RE + +.PP +\fB\-v\fR, \fB\-\-version\fR +.RS 4 +Print nfctool's version and exit. +.RE + +.PP +\fB\-l\fR, \fB\-\-list\fR +.RS 4 +List attached NFC devices. It also prints information such as remote tags or +devices, supported protocols, RF mode, and LLC link parameters. +.RE + +.PP +\fB\-d\fR, \fB\-\-device\fR=\fINFCDEV\fR +.RS 4 +Specify a nfc device (i.e. nfc0). This is mandatory for all operations except \fB\-l\fR. +.RE + +.PP +\fB\-p\fR, \fB\-\-poll\fR[=\fIMODE\fR] +.RS 4 +Start poll on the device specified with \fB\-d\fR. \fIMODE\fR must be one of +\fBInitiator\fR, \fBTarget\fR, or \fBBoth\fR and it defaults to \fBInitiator\fR +when unspecified. Passing \fIMODE\fR as \fBi\fR, \fBt\fR, or \fBb\fR for +respectively \fBInitiator\fR, \fBTarget\fR, or \fBBoth\fR is also accepted. +.RE + +.PP +\fB\-s\fR, \fB\-\-set\-param\fR=\fIPARAM=VAL\fR[,\fIPARAM=VAL\fR[,...]] +.RS 4 +Set LLC link parameters. \fIPARAM\fR must be at least one of: +.PP +\fBlto\fR=0..255 \- Link TimeOut +.RS 4 +Specify the maximum time interval between the last received LLC PDU from the +remote to the local LLC and the first subsequent LLC PDU transmission from the +local to the remote LLC. The value is expressed in multiples of 10 milliseconds +and is encoded as a 8-bit unsigned integer. +.PP +The LTO parameter must be set before the LLC Link is established. +.RE + +.PP +\fBrw\fR=0..15 \- Receive Window size +.RS 4 +Specify the maximum number of I PDUs the local LLC will accept before +acknowledging them. A RW size of zero indicates that the local LLC will not +accept I PDUs on that data link connection. A RW size of one indicates that the +local LLC will acknowledge every I PDU before accepting additional I PDUs. It is +encoded as a 4-bit unsigned integer. +.PP +The RW parameter can be set after the LLC Link is established. The new value +will apply for subsequent connections. +.RE +.PP +\fBmiux\fR=0..2047 \- Maximum Information Unit Extension +.RS 4 +Specify the number of octets by which a LLC PDU information field +may exceed the default maximum size of 128 octets. In other words, +MIU = MIUX + 128. It is encoded as an 11-bit unsigned integer. +.PP +The MIUX parameter can be set after the LLC Link is established. The new value +will apply for subsequent connections. +.RE +.RE + +.PP +\fB\-k\fR, \fB\-\-snl\fR=\fIURN\fR +.RS 4 +Send a Service Name Lookup request for \fIURN\fR (i.e. urn:nfc:sn:snep) to the +remote LLC. Obviously, the LLC link must be up before the request is sent. +.PP +The remote should reply by returning the service access point (SAP) number or +zero if it doesn't support the requested service. +.PP +\fBNote\fR: If used with -p, nfctool will wait for the LLC link to be up before +sending the SNL request. +.RE + +.PP +\fB\-n\fR, \fB\-\-sniff\fR +.RS 4 +Start LLCP sniffing on the device specified with \fB-d\fR option. + +.PP +\fBSNIFFER SPECIFIC OPTIONS\fR +.RS 4 +The folowing options only apply with \fR-n\fB. + +.PP +\fB\-a\fR, \fB\-\-snapshot\-len\fR=\fISNAPLEN\fR +.RS 4 +Capture \fISNAPLEN\fR bytes from each packet. Default snapshot length is 1024 +bytes. +.RE + +.PP +\fB\-y\fR, \fB\-\-dump\-symm\fR +.RS 4 +Dump SYMM packets to stdout. this will generate a \fBLOT\fR of output. +.PP +\fBNote\fR: The \fB-y\fR option concerns console output only. SYMM packets are +always dumped to the pcap file when specified by \fB-f\fR (See below). +.RE + +.PP +\fB\-t\fR, \fB\-\-show\-timestamp\fR[=\fIMODE\fR] +.RS 4 +Show packet timestamps. Setting \fIMODE\fR as \fBdelta\fR means the time since +the first captured frame. \fBabsolute\fR means elapsed time since the Epoch, +1970-01-01 00:00:00 +0000 (UTC). \fIMODE\fR defaults to \fBdelta\fR when +unspecified. +.RE + +.PP +\fB\-f\fR, \fB\-\-pcap\-file\fR=\fIFILENAME\fR +.RS 4 +Specify a filename to save dumped traffic in pcap format. The generated file can +be opened with Wireshark (http://www.wireshark.org/) using the wireshark-nfc +plug-in available at http://code.google.com/p/wireshark-nfc/ +.RE + +.RE +.RE + +.SH SEE ALSO +.PP +neard (8) +.PP +neard.conf (5) +.PP +Linux NFC project page at https://01.org/linux-nfc/
diff --git a/neard/doc/phdc-api.txt b/neard/doc/phdc-api.txt new file mode 100644 index 0000000..4d24195 --- /dev/null +++ b/neard/doc/phdc-api.txt
@@ -0,0 +1,80 @@ +PHDC hierarchy +============== +Service org.neard +Interface org.neard.PHDC +Object path /org/neard + +Methods void RegisterAgent(dict values) + + Register new PHDC agent. + + PHDC Manager or Agent implementations calls this + method in order to register themselves against neard. + PHDC Managers will be notified through their + NewConnection method of new PHDC Agents connections. + PHDC Agents will be nnotified through their + NewConnection method when a connection to a PHDC Manager + succeeded. + + Possible Errors: org.neard.Error.OutOfMemory + org.neard.Error.InvalidArguments + org.neard.Error.AlreadyExists + + void UnregisterAgent(object path, string role) + + Unregister an existing agent. + + Possible Errors: org.neard.Error.OutOfMemory + org.neard.Error.InvalidArguments + + +Fields string Role + + "Agent" or "Manager" (mandatory) + + object Path + + Agent or Manager path (mandatory) + + string ServiceName + + NFC urn to connect or to listen to + (default: "urn:nfc:sn:phdc"). + + +PHDC Manager hierarchy +====================== +Service unique name +Interface org.neard.PHDC.Manager +Object path freely definable + + +Methods: void NewConnection(fd agent) + + This method gets called when a PHDC Agent connects + using the p2p service name. The Phdc Manager uses + the given agent file descriptor to exchange data + with the Agent. + + void Disconnection(fd agent, error) + + This method is called when a PHDC Agent closes the + file descriptoer. + + void Release() + + This method is called when the service daemon + unregisters the agent. An agent can use it to do + cleanup tasks. + There is no need to unregister the agent, because + when this method gets called it has already been + unregistered. + + +PHDC Agent hierarchy +==================== +Service unique name +Interface org.neard.PHDC.Agent +Object path freely definable + +Methods: NOT YET IMPLEMENTED
diff --git a/neard/doc/se-manager-api.txt b/neard/doc/se-manager-api.txt new file mode 100644 index 0000000..095f571 --- /dev/null +++ b/neard/doc/se-manager-api.txt
@@ -0,0 +1,26 @@ +Manager hierarchy +================= + +Service org.neard.se +Interface org.neard.se.Manager +Object path / + +Methods dict GetProperties() + + Returns all properties for the manager. See the + properties section for available properties. + + Possible Errors: org.seeld.Error.DoesNotExist + +Signals SecureElementAdded(object se) + + Parameter is the object path of the added secure element. + + SecureElementRemoved(object se) + + Parameter is the object path of . + + +Properties array{object} SecureElements [readonly] + + List of secure element object paths.
diff --git a/neard/doc/secureelement-api.txt b/neard/doc/secureelement-api.txt new file mode 100644 index 0000000..4b117cd --- /dev/null +++ b/neard/doc/secureelement-api.txt
@@ -0,0 +1,101 @@ +Secure Element hierarchy +======================== + +Service org.neard.se +Interface org.neard.se.SecureElement +Object path [variable prefix]/{se0,se1,...} + + +Methods: dict GetProperties() + + Returns all properties for the secure element. See the + properties section for available properties. + + Possible Errors: org.seeld.Error.DoesNotExist + + void SetProperty(string name, variant value) + + Changes the value of the specified property. Only + properties that are listed a read-write are changeable. + On success this will emit a PropertyChanged signal. + + Possible Errors: org.seeld.Error.DoesNotExist + org.seeld.Error.InvalidArguments + + object OpenChannel(array{byte} AID) + + Open an ISO7816 logical channel to the secure element. + The AID (Application ID) array must be between 5 and 16 + bytes long. + The returned path is a Channel object path. + + Possible errors: org.seeld.Error.Failed + org.seeld.Error.InvalidArguments + org.seeld.Error.PermissionDenied + org.seeld.Error.NotSupported + + void CloseChannel(object channel) + + Close an ISO7816 channel, passed as an object path + argument. + + Possible errors: org.seeld.Error.Failed + org.seeld.Error.InvalidArguments + org.seeld.Error.PermissionDenied + org.seeld.Error.NotSupported + +Signals PropertyChanged(string name, variant value) + + This signal indicates a changed value of the given + property. + + +Properties string Type [readonly] + + The secure element type. + + Possible values are "Embedded", "UICC" or "ASSD". + + boolean Enabled [readwrite] + + Enable a secure element. + This will e.g. enable the SWP link for a UICC + based secure element. + + array{object} Channels [readonly] + + The opened channels object paths for this secure element. + + +Channel hierarchy +================= + +Service org.neard.se +Interface org.neard.se.Channel +Object path [variable prefix]/{se0}/{channel0,channel1,...} + +Methods: dict GetProperties() + + Returns all properties for the secure element. See the + properties section for available properties. + + Possible Errors: org.seeld.Error.DoesNotExist + + array{byte} SendAPDU(array{byte}) + + Send an ISO7816 APDU over this channel. + This is an asynchronous method and the returned array + is the response to the ISO7816 command. + + Possible errors: org.seeld.Error.Failed + org.seeld.Error.PermissionDenied + org.seeld.Error.NotSupported + + +Properties boolean Basic [readonly] + + Indicates if the channel is a basic one or not. + + array{byte} AID + + Associated Application ID.
diff --git a/neard/doc/tag-api.txt b/neard/doc/tag-api.txt new file mode 100644 index 0000000..f32fd06 --- /dev/null +++ b/neard/doc/tag-api.txt
@@ -0,0 +1,127 @@ +Tag hierarchy +================ + +Service org.neard +Interface org.neard.Tag +Object path [variable prefix]/{nfc0}/{tag0, tag1...} + +Method void Write(dict attributes) + + Creates an NDEF record from the attributes dictionary. + + The attribute argument should at least contain a + record type and is described by the Record properties. + For example, one would add a type, a Language, an + Encoding and a Representation for a text record. + + Possible Errors: org.neard.Error.PermissionDenied + org.neard.Error.InvalidArguments + org.neard.Error.InProgress + + +Properties string Type [readonly] + + The NFC tag type. + Possible values are "Type 1", "Type 2", "Type 3", + "Type 4", "Type 5", and "NFC-DEP". + + string Protocol [readonly] + + The tag radio protocol. + Possible values are "Felica", "MIFARE", "Jewel", + and "ISO-DEP". + + boolean ReadOnly [readonly] + + Give the current status of tag's read mode. + + object Adapter [readonly] + + The object path of the adapter the tag belongs to. + + +Record hierarchy +================ + +Service org.neard +Interface org.neard.Record +Object path [variable prefix]/{nfc0}/{tag0|device}/{record0,record1,...} + +Properties string Type [readonly] + + The NDEF record type name. + + Possible values are "SmartPoster", "Text", "URI", + "HandoverRequest", "HandoverSelect", "HandoverCarrier", + "AAR" for Android Application Record and "MIME" for + RFC 2046 MIME types. + + string Encoding [readonly] + + The character encoding. + + Possible values are "UTF-8" or "UTF-16". + This property is only valid for Text and SmartPoster's + title records. + + string Language [readonly] + + The ISO/IANA language code (For example "en" or "jp"). + + This property is only valid for Text and SmartPoster's + title records. + + string Representation [readonly] + + The human readable representation of a text or + title record. + + This property is only valid for Text and SmartPoster's + title records. + + string URI [readonly] + + The record URI (for example https://nfc-forum.org). + + This is the complete URI, including the scheme and + the resource. + This property is only valid for SmartPoster's URI + records. + + string MIMEType [readonly] + + The URI object MIME type. + + This is a description of the MIME type of the object + the URI points at. + This is not a mandatory field and is only valid for + Smart Posters carrying a URI record. + + uint32 Size [readonly] + + The URI object size. + + This is the size of the object the URI points at. + It should be used by applications to decide if they can + afford to fetch the object or not. + This is not a mandatory field and is only valid for + Smart Posters carrying a URI record. + + string Action [readonly] + + The suggested course of action. + + This one is only valid for Smart Posters and is a + suggestion only. It can be ignored, and the possible + values are "Do" (for example launch the browser), + "Save" (for example save the URI in the bookmarks + folder, or "Edit" (for example open the URI in an URI + editor for the user to modify it. + + string AndroidPackage [readonly] + + This is the Android Package Name contained in an + Android Application Record (AAR). It hints the reader + towards launching an Android specific application. + + It is only valid for AAR NDEFs.
diff --git a/neard/gdbus/client.c b/neard/gdbus/client.c new file mode 100644 index 0000000..eb68a0f --- /dev/null +++ b/neard/gdbus/client.c
@@ -0,0 +1,1377 @@ +/* + * + * D-Bus helper library + * + * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> + * + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <glib.h> +#include <dbus/dbus.h> + +#include "gdbus.h" + +#define METHOD_CALL_TIMEOUT (300 * 1000) + +#ifndef DBUS_INTERFACE_OBJECT_MANAGER +#define DBUS_INTERFACE_OBJECT_MANAGER DBUS_INTERFACE_DBUS ".ObjectManager" +#endif + +struct GDBusClient { + int ref_count; + DBusConnection *dbus_conn; + char *service_name; + char *base_path; + guint watch; + guint added_watch; + guint removed_watch; + GPtrArray *match_rules; + DBusPendingCall *pending_call; + DBusPendingCall *get_objects_call; + GDBusWatchFunction connect_func; + void *connect_data; + GDBusWatchFunction disconn_func; + gboolean connected; + void *disconn_data; + GDBusMessageFunction signal_func; + void *signal_data; + GDBusProxyFunction proxy_added; + GDBusProxyFunction proxy_removed; + GDBusClientFunction ready; + void *ready_data; + GDBusPropertyFunction property_changed; + void *user_data; + GList *proxy_list; +}; + +struct GDBusProxy { + int ref_count; + GDBusClient *client; + char *obj_path; + char *interface; + GHashTable *prop_list; + guint watch; + GDBusPropertyFunction prop_func; + void *prop_data; + GDBusProxyFunction removed_func; + void *removed_data; +}; + +struct prop_entry { + char *name; + int type; + DBusMessage *msg; +}; + +static void modify_match_reply(DBusPendingCall *call, void *user_data) +{ + DBusMessage *reply = dbus_pending_call_steal_reply(call); + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply) == TRUE) + dbus_error_free(&error); + + dbus_message_unref(reply); +} + +static gboolean modify_match(DBusConnection *conn, const char *member, + const char *rule) +{ + DBusMessage *msg; + DBusPendingCall *call; + + msg = dbus_message_new_method_call(DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, member); + if (msg == NULL) + return FALSE; + + dbus_message_append_args(msg, DBUS_TYPE_STRING, &rule, + DBUS_TYPE_INVALID); + + if (g_dbus_send_message_with_reply(conn, msg, &call, -1) == FALSE) { + dbus_message_unref(msg); + return FALSE; + } + + dbus_pending_call_set_notify(call, modify_match_reply, NULL, NULL); + dbus_pending_call_unref(call); + + dbus_message_unref(msg); + + return TRUE; +} + +static void iter_append_iter(DBusMessageIter *base, DBusMessageIter *iter) +{ + int type; + + type = dbus_message_iter_get_arg_type(iter); + + if (dbus_type_is_basic(type)) { + const void *value; + + dbus_message_iter_get_basic(iter, &value); + dbus_message_iter_append_basic(base, type, &value); + } else if (dbus_type_is_container(type)) { + DBusMessageIter iter_sub, base_sub; + char *sig; + + dbus_message_iter_recurse(iter, &iter_sub); + + switch (type) { + case DBUS_TYPE_ARRAY: + case DBUS_TYPE_VARIANT: + sig = dbus_message_iter_get_signature(&iter_sub); + break; + default: + sig = NULL; + break; + } + + dbus_message_iter_open_container(base, type, sig, &base_sub); + + if (sig != NULL) + dbus_free(sig); + + while (dbus_message_iter_get_arg_type(&iter_sub) != + DBUS_TYPE_INVALID) { + iter_append_iter(&base_sub, &iter_sub); + dbus_message_iter_next(&iter_sub); + } + + dbus_message_iter_close_container(base, &base_sub); + } +} + +static void prop_entry_update(struct prop_entry *prop, DBusMessageIter *iter) +{ + DBusMessage *msg; + DBusMessageIter base; + + msg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); + if (msg == NULL) + return; + + dbus_message_iter_init_append(msg, &base); + iter_append_iter(&base, iter); + + if (prop->msg != NULL) + dbus_message_unref(prop->msg); + + prop->msg = dbus_message_copy(msg); + dbus_message_unref(msg); +} + +static struct prop_entry *prop_entry_new(const char *name, + DBusMessageIter *iter) +{ + struct prop_entry *prop; + + prop = g_try_new0(struct prop_entry, 1); + if (prop == NULL) + return NULL; + + prop->name = g_strdup(name); + prop->type = dbus_message_iter_get_arg_type(iter); + + prop_entry_update(prop, iter); + + return prop; +} + +static void prop_entry_free(gpointer data) +{ + struct prop_entry *prop = data; + + if (prop->msg != NULL) + dbus_message_unref(prop->msg); + + g_free(prop->name); + + g_free(prop); +} + +static void add_property(GDBusProxy *proxy, const char *name, + DBusMessageIter *iter, gboolean send_changed) +{ + GDBusClient *client = proxy->client; + DBusMessageIter value; + struct prop_entry *prop; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT) + return; + + dbus_message_iter_recurse(iter, &value); + + prop = g_hash_table_lookup(proxy->prop_list, name); + if (prop != NULL) { + prop_entry_update(prop, &value); + goto done; + } + + prop = prop_entry_new(name, &value); + if (prop == NULL) + return; + + g_hash_table_replace(proxy->prop_list, prop->name, prop); + +done: + if (proxy->prop_func) + proxy->prop_func(proxy, name, &value, proxy->prop_data); + + if (client == NULL || send_changed == FALSE) + return; + + if (client->property_changed) + client->property_changed(proxy, name, &value, + client->user_data); +} + +static void update_properties(GDBusProxy *proxy, DBusMessageIter *iter, + gboolean send_changed) +{ + DBusMessageIter dict; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) + return; + + dbus_message_iter_recurse(iter, &dict); + + while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter entry; + const char *name; + + dbus_message_iter_recurse(&dict, &entry); + + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) + break; + + dbus_message_iter_get_basic(&entry, &name); + dbus_message_iter_next(&entry); + + add_property(proxy, name, &entry, send_changed); + + dbus_message_iter_next(&dict); + } +} + +static void get_all_properties_reply(DBusPendingCall *call, void *user_data) +{ + GDBusProxy *proxy = user_data; + GDBusClient *client = proxy->client; + DBusMessage *reply = dbus_pending_call_steal_reply(call); + DBusMessageIter iter; + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply) == TRUE) { + dbus_error_free(&error); + goto done; + } + + dbus_message_iter_init(reply, &iter); + + update_properties(proxy, &iter, FALSE); + +done: + if (g_list_find(client->proxy_list, proxy) == NULL) { + if (client->proxy_added) + client->proxy_added(proxy, client->user_data); + + client->proxy_list = g_list_append(client->proxy_list, proxy); + } + + dbus_message_unref(reply); + + g_dbus_client_unref(client); +} + +static void get_all_properties(GDBusProxy *proxy) +{ + GDBusClient *client = proxy->client; + const char *service_name = client->service_name; + DBusMessage *msg; + DBusPendingCall *call; + + msg = dbus_message_new_method_call(service_name, proxy->obj_path, + DBUS_INTERFACE_PROPERTIES, "GetAll"); + if (msg == NULL) + return; + + dbus_message_append_args(msg, DBUS_TYPE_STRING, &proxy->interface, + DBUS_TYPE_INVALID); + + if (g_dbus_send_message_with_reply(client->dbus_conn, msg, + &call, -1) == FALSE) { + dbus_message_unref(msg); + return; + } + + g_dbus_client_ref(client); + + dbus_pending_call_set_notify(call, get_all_properties_reply, + proxy, NULL); + dbus_pending_call_unref(call); + + dbus_message_unref(msg); +} + +static GDBusProxy *proxy_lookup(GDBusClient *client, const char *path, + const char *interface) +{ + GList *list; + + for (list = g_list_first(client->proxy_list); list; + list = g_list_next(list)) { + GDBusProxy *proxy = list->data; + + if (g_str_equal(proxy->interface, interface) == TRUE && + g_str_equal(proxy->obj_path, path) == TRUE) + return proxy; + } + + return NULL; +} + +static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg, + void *user_data) +{ + GDBusProxy *proxy = user_data; + GDBusClient *client = proxy->client; + DBusMessageIter iter, entry; + const char *interface; + + if (dbus_message_iter_init(msg, &iter) == FALSE) + return TRUE; + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + return TRUE; + + dbus_message_iter_get_basic(&iter, &interface); + dbus_message_iter_next(&iter); + + update_properties(proxy, &iter, TRUE); + + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) + return TRUE; + + dbus_message_iter_recurse(&iter, &entry); + + while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRING) { + const char *name; + + dbus_message_iter_get_basic(&entry, &name); + + g_hash_table_remove(proxy->prop_list, name); + + if (proxy->prop_func) + proxy->prop_func(proxy, name, NULL, proxy->prop_data); + + if (client->property_changed) + client->property_changed(proxy, name, NULL, + client->user_data); + + dbus_message_iter_next(&entry); + } + + return TRUE; +} + +static GDBusProxy *proxy_new(GDBusClient *client, const char *path, + const char *interface) +{ + GDBusProxy *proxy; + + proxy = g_try_new0(GDBusProxy, 1); + if (proxy == NULL) + return NULL; + + proxy->client = client; + proxy->obj_path = g_strdup(path); + proxy->interface = g_strdup(interface); + + proxy->prop_list = g_hash_table_new_full(g_str_hash, g_str_equal, + NULL, prop_entry_free); + proxy->watch = g_dbus_add_properties_watch(client->dbus_conn, + client->service_name, + proxy->obj_path, + proxy->interface, + properties_changed, + proxy, NULL); + + return g_dbus_proxy_ref(proxy); +} + +static void proxy_free(gpointer data) +{ + GDBusProxy *proxy = data; + + if (proxy->client) { + GDBusClient *client = proxy->client; + + if (client->proxy_removed) + client->proxy_removed(proxy, client->user_data); + + g_dbus_remove_watch(client->dbus_conn, proxy->watch); + + g_hash_table_remove_all(proxy->prop_list); + + proxy->client = NULL; + } + + if (proxy->removed_func) + proxy->removed_func(proxy, proxy->removed_data); + + g_dbus_proxy_unref(proxy); +} + +static void proxy_remove(GDBusClient *client, const char *path, + const char *interface) +{ + GList *list; + + for (list = g_list_first(client->proxy_list); list; + list = g_list_next(list)) { + GDBusProxy *proxy = list->data; + + if (g_str_equal(proxy->interface, interface) == TRUE && + g_str_equal(proxy->obj_path, path) == TRUE) { + client->proxy_list = + g_list_delete_link(client->proxy_list, list); + proxy_free(proxy); + break; + } + } +} + +GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path, + const char *interface) +{ + GDBusProxy *proxy; + + if (client == NULL) + return NULL; + + proxy = proxy_lookup(client, path, interface); + if (proxy) + return g_dbus_proxy_ref(proxy); + + proxy = proxy_new(client, path, interface); + if (proxy == NULL) + return NULL; + + get_all_properties(proxy); + + return g_dbus_proxy_ref(proxy); +} + +GDBusProxy *g_dbus_proxy_ref(GDBusProxy *proxy) +{ + if (proxy == NULL) + return NULL; + + __sync_fetch_and_add(&proxy->ref_count, 1); + + return proxy; +} + +void g_dbus_proxy_unref(GDBusProxy *proxy) +{ + if (proxy == NULL) + return; + + if (__sync_sub_and_fetch(&proxy->ref_count, 1) > 0) + return; + + g_hash_table_destroy(proxy->prop_list); + + g_free(proxy->obj_path); + g_free(proxy->interface); + + g_free(proxy); +} + +const char *g_dbus_proxy_get_path(GDBusProxy *proxy) +{ + if (proxy == NULL) + return NULL; + + return proxy->obj_path; +} + +const char *g_dbus_proxy_get_interface(GDBusProxy *proxy) +{ + if (proxy == NULL) + return NULL; + + return proxy->interface; +} + +gboolean g_dbus_proxy_get_property(GDBusProxy *proxy, const char *name, + DBusMessageIter *iter) +{ + struct prop_entry *prop; + + if (proxy == NULL || name == NULL) + return FALSE; + + prop = g_hash_table_lookup(proxy->prop_list, name); + if (prop == NULL) + return FALSE; + + if (prop->msg == NULL) + return FALSE; + + if (dbus_message_iter_init(prop->msg, iter) == FALSE) + return FALSE; + + return TRUE; +} + +struct refresh_property_data { + GDBusProxy *proxy; + char *name; +}; + +static void refresh_property_free(gpointer user_data) +{ + struct refresh_property_data *data = user_data; + + g_free(data->name); + g_free(data); +} + +static void refresh_property_reply(DBusPendingCall *call, void *user_data) +{ + struct refresh_property_data *data = user_data; + DBusMessage *reply = dbus_pending_call_steal_reply(call); + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply) == FALSE) { + DBusMessageIter iter; + + dbus_message_iter_init(reply, &iter); + + add_property(data->proxy, data->name, &iter, TRUE); + } else + dbus_error_free(&error); + + dbus_message_unref(reply); +} + +gboolean g_dbus_proxy_refresh_property(GDBusProxy *proxy, const char *name) +{ + struct refresh_property_data *data; + GDBusClient *client; + DBusMessage *msg; + DBusMessageIter iter; + DBusPendingCall *call; + + if (proxy == NULL || name == NULL) + return FALSE; + + client = proxy->client; + if (client == NULL) + return FALSE; + + data = g_try_new0(struct refresh_property_data, 1); + if (data == NULL) + return FALSE; + + data->proxy = proxy; + data->name = g_strdup(name); + + msg = dbus_message_new_method_call(client->service_name, + proxy->obj_path, DBUS_INTERFACE_PROPERTIES, "Get"); + if (msg == NULL) { + refresh_property_free(data); + return FALSE; + } + + dbus_message_iter_init_append(msg, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, + &proxy->interface); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name); + + if (g_dbus_send_message_with_reply(client->dbus_conn, msg, + &call, -1) == FALSE) { + dbus_message_unref(msg); + refresh_property_free(data); + return FALSE; + } + + dbus_pending_call_set_notify(call, refresh_property_reply, + data, refresh_property_free); + dbus_pending_call_unref(call); + + dbus_message_unref(msg); + + return TRUE; +} + +struct set_property_data { + GDBusResultFunction function; + void *user_data; + GDBusDestroyFunction destroy; +}; + +static void set_property_reply(DBusPendingCall *call, void *user_data) +{ + struct set_property_data *data = user_data; + DBusMessage *reply = dbus_pending_call_steal_reply(call); + DBusError error; + + dbus_error_init(&error); + + dbus_set_error_from_message(&error, reply); + + if (data->function) + data->function(&error, data->user_data); + + if (data->destroy) + data->destroy(data->user_data); + + dbus_error_free(&error); + + dbus_message_unref(reply); +} + +gboolean g_dbus_proxy_set_property_basic(GDBusProxy *proxy, + const char *name, int type, const void *value, + GDBusResultFunction function, void *user_data, + GDBusDestroyFunction destroy) +{ + struct set_property_data *data; + GDBusClient *client; + DBusMessage *msg; + DBusMessageIter iter, variant; + DBusPendingCall *call; + char type_as_str[2]; + + if (proxy == NULL || name == NULL || value == NULL) + return FALSE; + + if (dbus_type_is_basic(type) == FALSE) + return FALSE; + + client = proxy->client; + if (client == NULL) + return FALSE; + + data = g_try_new0(struct set_property_data, 1); + if (data == NULL) + return FALSE; + + data->function = function; + data->user_data = user_data; + data->destroy = destroy; + + msg = dbus_message_new_method_call(client->service_name, + proxy->obj_path, DBUS_INTERFACE_PROPERTIES, "Set"); + if (msg == NULL) { + g_free(data); + return FALSE; + } + + type_as_str[0] = (char) type; + type_as_str[1] = '\0'; + + dbus_message_iter_init_append(msg, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, + &proxy->interface); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, + type_as_str, &variant); + dbus_message_iter_append_basic(&variant, type, value); + dbus_message_iter_close_container(&iter, &variant); + + if (g_dbus_send_message_with_reply(client->dbus_conn, msg, + &call, -1) == FALSE) { + dbus_message_unref(msg); + g_free(data); + return FALSE; + } + + dbus_pending_call_set_notify(call, set_property_reply, data, g_free); + dbus_pending_call_unref(call); + + dbus_message_unref(msg); + + return TRUE; +} + +gboolean g_dbus_proxy_set_property_array(GDBusProxy *proxy, + const char *name, int type, const void *value, + size_t size, GDBusResultFunction function, + void *user_data, GDBusDestroyFunction destroy) +{ + struct set_property_data *data; + GDBusClient *client; + DBusMessage *msg; + DBusMessageIter iter, variant, array; + DBusPendingCall *call; + char array_sig[3]; + char type_sig[2]; + + if (!proxy || !name || !value) + return FALSE; + + if (!dbus_type_is_basic(type)) + return FALSE; + + client = proxy->client; + if (!client) + return FALSE; + + data = g_try_new0(struct set_property_data, 1); + if (!data) + return FALSE; + + data->function = function; + data->user_data = user_data; + data->destroy = destroy; + + msg = dbus_message_new_method_call(client->service_name, + proxy->obj_path, + DBUS_INTERFACE_PROPERTIES, + "Set"); + if (!msg) { + g_free(data); + return FALSE; + } + + array_sig[0] = DBUS_TYPE_ARRAY; + array_sig[1] = (char) type; + array_sig[2] = '\0'; + + type_sig[0] = (char) type; + type_sig[1] = '\0'; + + dbus_message_iter_init_append(msg, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, + &proxy->interface); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, + array_sig, &variant); + + dbus_message_iter_open_container(&variant, DBUS_TYPE_ARRAY, + type_sig, &array); + + if (dbus_type_is_fixed(type)) + dbus_message_iter_append_fixed_array(&array, type, &value, + size); + else if (type == DBUS_TYPE_STRING || type == DBUS_TYPE_OBJECT_PATH) { + const char **str = (const char **) value; + size_t i; + + for (i = 0; i < size; i++) + dbus_message_iter_append_basic(&array, type, &str[i]); + } + + dbus_message_iter_close_container(&variant, &array); + dbus_message_iter_close_container(&iter, &variant); + + if (g_dbus_send_message_with_reply(client->dbus_conn, msg, + &call, -1) == FALSE) { + dbus_message_unref(msg); + g_free(data); + return FALSE; + } + + dbus_pending_call_set_notify(call, set_property_reply, data, g_free); + dbus_pending_call_unref(call); + + dbus_message_unref(msg); + + return TRUE; +} + +struct method_call_data { + GDBusReturnFunction function; + void *user_data; + GDBusDestroyFunction destroy; +}; + +static void method_call_reply(DBusPendingCall *call, void *user_data) +{ + struct method_call_data *data = user_data; + DBusMessage *reply = dbus_pending_call_steal_reply(call); + + if (data->function) + data->function(reply, data->user_data); + + if (data->destroy) + data->destroy(data->user_data); + + dbus_message_unref(reply); +} + +gboolean g_dbus_proxy_method_call(GDBusProxy *proxy, const char *method, + GDBusSetupFunction setup, + GDBusReturnFunction function, void *user_data, + GDBusDestroyFunction destroy) +{ + struct method_call_data *data; + GDBusClient *client; + DBusMessage *msg; + DBusPendingCall *call; + + if (proxy == NULL || method == NULL) + return FALSE; + + client = proxy->client; + if (client == NULL) + return FALSE; + + data = g_try_new0(struct method_call_data, 1); + if (data == NULL) + return FALSE; + + data->function = function; + data->user_data = user_data; + data->destroy = destroy; + + msg = dbus_message_new_method_call(client->service_name, + proxy->obj_path, proxy->interface, method); + if (msg == NULL) { + g_free(data); + return FALSE; + } + + if (setup) { + DBusMessageIter iter; + + dbus_message_iter_init_append(msg, &iter); + setup(&iter, data->user_data); + } + + if (g_dbus_send_message_with_reply(client->dbus_conn, msg, + &call, METHOD_CALL_TIMEOUT) == FALSE) { + dbus_message_unref(msg); + g_free(data); + return FALSE; + } + + dbus_pending_call_set_notify(call, method_call_reply, data, g_free); + dbus_pending_call_unref(call); + + dbus_message_unref(msg); + + return TRUE; +} + +gboolean g_dbus_proxy_set_property_watch(GDBusProxy *proxy, + GDBusPropertyFunction function, void *user_data) +{ + if (proxy == NULL) + return FALSE; + + proxy->prop_func = function; + proxy->prop_data = user_data; + + return TRUE; +} + +gboolean g_dbus_proxy_set_removed_watch(GDBusProxy *proxy, + GDBusProxyFunction function, void *user_data) +{ + if (proxy == NULL) + return FALSE; + + proxy->removed_func = function; + proxy->removed_data = user_data; + + return TRUE; +} + +static void refresh_properties(GDBusClient *client) +{ + GList *list; + + for (list = g_list_first(client->proxy_list); list; + list = g_list_next(list)) { + GDBusProxy *proxy = list->data; + + get_all_properties(proxy); + } +} + +static void parse_properties(GDBusClient *client, const char *path, + const char *interface, DBusMessageIter *iter) +{ + GDBusProxy *proxy; + + if (g_str_equal(interface, DBUS_INTERFACE_INTROSPECTABLE) == TRUE) + return; + + if (g_str_equal(interface, DBUS_INTERFACE_PROPERTIES) == TRUE) + return; + + proxy = proxy_lookup(client, path, interface); + if (proxy) { + update_properties(proxy, iter, FALSE); + return; + } + + proxy = proxy_new(client, path, interface); + if (proxy == NULL) + return; + + update_properties(proxy, iter, FALSE); + + if (client->proxy_added) + client->proxy_added(proxy, client->user_data); + + client->proxy_list = g_list_append(client->proxy_list, proxy); +} + +static void parse_interfaces(GDBusClient *client, const char *path, + DBusMessageIter *iter) +{ + DBusMessageIter dict; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) + return; + + dbus_message_iter_recurse(iter, &dict); + + while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter entry; + const char *interface; + + dbus_message_iter_recurse(&dict, &entry); + + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING) + break; + + dbus_message_iter_get_basic(&entry, &interface); + dbus_message_iter_next(&entry); + + parse_properties(client, path, interface, &entry); + + dbus_message_iter_next(&dict); + } +} + +static gboolean interfaces_added(DBusConnection *conn, DBusMessage *msg, + void *user_data) +{ + GDBusClient *client = user_data; + DBusMessageIter iter; + const char *path; + + if (dbus_message_iter_init(msg, &iter) == FALSE) + return TRUE; + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH) + return TRUE; + + dbus_message_iter_get_basic(&iter, &path); + dbus_message_iter_next(&iter); + + g_dbus_client_ref(client); + + parse_interfaces(client, path, &iter); + + g_dbus_client_unref(client); + + return TRUE; +} + +static gboolean interfaces_removed(DBusConnection *conn, DBusMessage *msg, + void *user_data) +{ + GDBusClient *client = user_data; + DBusMessageIter iter, entry; + const char *path; + + if (dbus_message_iter_init(msg, &iter) == FALSE) + return TRUE; + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH) + return TRUE; + + dbus_message_iter_get_basic(&iter, &path); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) + return TRUE; + + dbus_message_iter_recurse(&iter, &entry); + + g_dbus_client_ref(client); + + while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRING) { + const char *interface; + + dbus_message_iter_get_basic(&entry, &interface); + proxy_remove(client, path, interface); + dbus_message_iter_next(&entry); + } + + g_dbus_client_unref(client); + + return TRUE; +} + +static void parse_managed_objects(GDBusClient *client, DBusMessage *msg) +{ + DBusMessageIter iter, dict; + + if (dbus_message_iter_init(msg, &iter) == FALSE) + return; + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) + return; + + dbus_message_iter_recurse(&iter, &dict); + + while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter entry; + const char *path; + + dbus_message_iter_recurse(&dict, &entry); + + if (dbus_message_iter_get_arg_type(&entry) != + DBUS_TYPE_OBJECT_PATH) + break; + + dbus_message_iter_get_basic(&entry, &path); + dbus_message_iter_next(&entry); + + parse_interfaces(client, path, &entry); + + dbus_message_iter_next(&dict); + } + + if (client->ready) + client->ready(client, client->ready_data); +} + +static void get_managed_objects_reply(DBusPendingCall *call, void *user_data) +{ + GDBusClient *client = user_data; + DBusMessage *reply = dbus_pending_call_steal_reply(call); + DBusError error; + + g_dbus_client_ref(client); + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply) == TRUE) { + dbus_error_free(&error); + goto done; + } + + parse_managed_objects(client, reply); + +done: + dbus_message_unref(reply); + + dbus_pending_call_unref(client->get_objects_call); + client->get_objects_call = NULL; + + g_dbus_client_unref(client); +} + +static void get_managed_objects(GDBusClient *client) +{ + DBusMessage *msg; + + if (!client->proxy_added && !client->proxy_removed) { + refresh_properties(client); + return; + } + + if (client->get_objects_call != NULL) + return; + + msg = dbus_message_new_method_call(client->service_name, "/", + DBUS_INTERFACE_DBUS ".ObjectManager", + "GetManagedObjects"); + if (msg == NULL) + return; + + dbus_message_append_args(msg, DBUS_TYPE_INVALID); + + if (g_dbus_send_message_with_reply(client->dbus_conn, msg, + &client->get_objects_call, -1) == FALSE) { + dbus_message_unref(msg); + return; + } + + dbus_pending_call_set_notify(client->get_objects_call, + get_managed_objects_reply, + client, NULL); + + dbus_message_unref(msg); +} + +static void service_connect(DBusConnection *conn, void *user_data) +{ + GDBusClient *client = user_data; + + g_dbus_client_ref(client); + + if (client->connect_func) + client->connect_func(conn, client->connect_data); + + get_managed_objects(client); + + client->connected = TRUE; + + g_dbus_client_unref(client); +} + +static void service_disconnect(DBusConnection *conn, void *user_data) +{ + GDBusClient *client = user_data; + + g_list_free_full(client->proxy_list, proxy_free); + client->proxy_list = NULL; + + if (client->disconn_func) { + client->disconn_func(conn, client->disconn_data); + client->connected = FALSE; + } +} + +static DBusHandlerResult message_filter(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + GDBusClient *client = user_data; + const char *sender, *path, *interface; + + if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + sender = dbus_message_get_sender(message); + if (sender == NULL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + path = dbus_message_get_path(message); + interface = dbus_message_get_interface(message); + + if (g_str_has_prefix(path, client->base_path) == FALSE) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (g_str_equal(interface, DBUS_INTERFACE_PROPERTIES) == TRUE) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (client->signal_func) + client->signal_func(connection, message, client->signal_data); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +GDBusClient *g_dbus_client_new(DBusConnection *connection, + const char *service, const char *path) +{ + GDBusClient *client; + unsigned int i; + + if (connection == NULL) + return NULL; + + client = g_try_new0(GDBusClient, 1); + if (client == NULL) + return NULL; + + if (dbus_connection_add_filter(connection, message_filter, + client, NULL) == FALSE) { + g_free(client); + return NULL; + } + + client->dbus_conn = dbus_connection_ref(connection); + client->service_name = g_strdup(service); + client->base_path = g_strdup(path); + client->connected = FALSE; + + client->match_rules = g_ptr_array_sized_new(1); + g_ptr_array_set_free_func(client->match_rules, g_free); + + client->watch = g_dbus_add_service_watch(connection, service, + service_connect, + service_disconnect, + client, NULL); + client->added_watch = g_dbus_add_signal_watch(connection, service, + "/", + DBUS_INTERFACE_OBJECT_MANAGER, + "InterfacesAdded", + interfaces_added, + client, NULL); + client->removed_watch = g_dbus_add_signal_watch(connection, service, + "/", + DBUS_INTERFACE_OBJECT_MANAGER, + "InterfacesRemoved", + interfaces_removed, + client, NULL); + g_ptr_array_add(client->match_rules, g_strdup_printf("type='signal'," + "sender='%s',path_namespace='%s'", + client->service_name, client->base_path)); + + for (i = 0; i < client->match_rules->len; i++) { + modify_match(client->dbus_conn, "AddMatch", + g_ptr_array_index(client->match_rules, i)); + } + + return g_dbus_client_ref(client); +} + +GDBusClient *g_dbus_client_ref(GDBusClient *client) +{ + if (client == NULL) + return NULL; + + __sync_fetch_and_add(&client->ref_count, 1); + + return client; +} + +void g_dbus_client_unref(GDBusClient *client) +{ + unsigned int i; + + if (client == NULL) + return; + + if (__sync_sub_and_fetch(&client->ref_count, 1) > 0) + return; + + if (client->pending_call != NULL) { + dbus_pending_call_cancel(client->pending_call); + dbus_pending_call_unref(client->pending_call); + } + + if (client->get_objects_call != NULL) { + dbus_pending_call_cancel(client->get_objects_call); + dbus_pending_call_unref(client->get_objects_call); + } + + for (i = 0; i < client->match_rules->len; i++) { + modify_match(client->dbus_conn, "RemoveMatch", + g_ptr_array_index(client->match_rules, i)); + } + + g_ptr_array_free(client->match_rules, TRUE); + + dbus_connection_remove_filter(client->dbus_conn, + message_filter, client); + + g_list_free_full(client->proxy_list, proxy_free); + + /* + * Don't call disconn_func twice if disconnection + * was previously reported. + */ + if (client->disconn_func && client->connected) + client->disconn_func(client->dbus_conn, client->disconn_data); + + g_dbus_remove_watch(client->dbus_conn, client->watch); + g_dbus_remove_watch(client->dbus_conn, client->added_watch); + g_dbus_remove_watch(client->dbus_conn, client->removed_watch); + + dbus_connection_unref(client->dbus_conn); + + g_free(client->service_name); + g_free(client->base_path); + + g_free(client); +} + +gboolean g_dbus_client_set_connect_watch(GDBusClient *client, + GDBusWatchFunction function, void *user_data) +{ + if (client == NULL) + return FALSE; + + client->connect_func = function; + client->connect_data = user_data; + + return TRUE; +} + +gboolean g_dbus_client_set_disconnect_watch(GDBusClient *client, + GDBusWatchFunction function, void *user_data) +{ + if (client == NULL) + return FALSE; + + client->disconn_func = function; + client->disconn_data = user_data; + + return TRUE; +} + +gboolean g_dbus_client_set_signal_watch(GDBusClient *client, + GDBusMessageFunction function, void *user_data) +{ + if (client == NULL) + return FALSE; + + client->signal_func = function; + client->signal_data = user_data; + + return TRUE; +} + +gboolean g_dbus_client_set_ready_watch(GDBusClient *client, + GDBusClientFunction ready, void *user_data) +{ + if (client == NULL) + return FALSE; + + client->ready = ready; + client->ready_data = user_data; + + return TRUE; +} + +gboolean g_dbus_client_set_proxy_handlers(GDBusClient *client, + GDBusProxyFunction proxy_added, + GDBusProxyFunction proxy_removed, + GDBusPropertyFunction property_changed, + void *user_data) +{ + if (client == NULL) + return FALSE; + + client->proxy_added = proxy_added; + client->proxy_removed = proxy_removed; + client->property_changed = property_changed; + client->user_data = user_data; + + get_managed_objects(client); + + return TRUE; +}
diff --git a/neard/gdbus/gdbus.h b/neard/gdbus/gdbus.h new file mode 100644 index 0000000..551c306 --- /dev/null +++ b/neard/gdbus/gdbus.h
@@ -0,0 +1,380 @@ +/* + * + * D-Bus helper library + * + * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> + * + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __GDBUS_H +#define __GDBUS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <dbus/dbus.h> +#include <glib.h> + +typedef enum GDBusMethodFlags GDBusMethodFlags; +typedef enum GDBusSignalFlags GDBusSignalFlags; +typedef enum GDBusPropertyFlags GDBusPropertyFlags; +typedef enum GDBusSecurityFlags GDBusSecurityFlags; + +typedef struct GDBusArgInfo GDBusArgInfo; +typedef struct GDBusMethodTable GDBusMethodTable; +typedef struct GDBusSignalTable GDBusSignalTable; +typedef struct GDBusPropertyTable GDBusPropertyTable; +typedef struct GDBusSecurityTable GDBusSecurityTable; + +typedef void (* GDBusWatchFunction) (DBusConnection *connection, + void *user_data); + +typedef void (* GDBusMessageFunction) (DBusConnection *connection, + DBusMessage *message, void *user_data); + +typedef gboolean (* GDBusSignalFunction) (DBusConnection *connection, + DBusMessage *message, void *user_data); + +DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, + DBusError *error); + +DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name, + DBusError *error); + +gboolean g_dbus_request_name(DBusConnection *connection, const char *name, + DBusError *error); + +gboolean g_dbus_set_disconnect_function(DBusConnection *connection, + GDBusWatchFunction function, + void *user_data, DBusFreeFunction destroy); + +typedef void (* GDBusDestroyFunction) (void *user_data); + +typedef DBusMessage * (* GDBusMethodFunction) (DBusConnection *connection, + DBusMessage *message, void *user_data); + +typedef gboolean (*GDBusPropertyGetter)(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data); + +typedef guint32 GDBusPendingPropertySet; + +typedef void (*GDBusPropertySetter)(const GDBusPropertyTable *property, + DBusMessageIter *value, GDBusPendingPropertySet id, + void *data); + +typedef gboolean (*GDBusPropertyExists)(const GDBusPropertyTable *property, + void *data); + +typedef guint32 GDBusPendingReply; + +typedef void (* GDBusSecurityFunction) (DBusConnection *connection, + const char *action, + gboolean interaction, + GDBusPendingReply pending); + +enum GDBusFlags { + G_DBUS_FLAG_ENABLE_EXPERIMENTAL = (1 << 0), +}; + +enum GDBusMethodFlags { + G_DBUS_METHOD_FLAG_DEPRECATED = (1 << 0), + G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1), + G_DBUS_METHOD_FLAG_ASYNC = (1 << 2), + G_DBUS_METHOD_FLAG_EXPERIMENTAL = (1 << 3), +}; + +enum GDBusSignalFlags { + G_DBUS_SIGNAL_FLAG_DEPRECATED = (1 << 0), + G_DBUS_SIGNAL_FLAG_EXPERIMENTAL = (1 << 1), +}; + +enum GDBusPropertyFlags { + G_DBUS_PROPERTY_FLAG_DEPRECATED = (1 << 0), + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL = (1 << 1), +}; + +enum GDBusSecurityFlags { + G_DBUS_SECURITY_FLAG_DEPRECATED = (1 << 0), + G_DBUS_SECURITY_FLAG_BUILTIN = (1 << 1), + G_DBUS_SECURITY_FLAG_ALLOW_INTERACTION = (1 << 2), +}; + +struct GDBusArgInfo { + const char *name; + const char *signature; +}; + +struct GDBusMethodTable { + const char *name; + GDBusMethodFunction function; + GDBusMethodFlags flags; + unsigned int privilege; + const GDBusArgInfo *in_args; + const GDBusArgInfo *out_args; +}; + +struct GDBusSignalTable { + const char *name; + GDBusSignalFlags flags; + const GDBusArgInfo *args; +}; + +struct GDBusPropertyTable { + const char *name; + const char *type; + GDBusPropertyGetter get; + GDBusPropertySetter set; + GDBusPropertyExists exists; + GDBusPropertyFlags flags; +}; + +struct GDBusSecurityTable { + unsigned int privilege; + const char *action; + GDBusSecurityFlags flags; + GDBusSecurityFunction function; +}; + +#define GDBUS_ARGS(args...) (const GDBusArgInfo[]) { args, { } } + +#define GDBUS_METHOD(_name, _in_args, _out_args, _function) \ + .name = _name, \ + .in_args = _in_args, \ + .out_args = _out_args, \ + .function = _function + +#define GDBUS_ASYNC_METHOD(_name, _in_args, _out_args, _function) \ + .name = _name, \ + .in_args = _in_args, \ + .out_args = _out_args, \ + .function = _function, \ + .flags = G_DBUS_METHOD_FLAG_ASYNC + +#define GDBUS_DEPRECATED_METHOD(_name, _in_args, _out_args, _function) \ + .name = _name, \ + .in_args = _in_args, \ + .out_args = _out_args, \ + .function = _function, \ + .flags = G_DBUS_METHOD_FLAG_DEPRECATED + +#define GDBUS_DEPRECATED_ASYNC_METHOD(_name, _in_args, _out_args, _function) \ + .name = _name, \ + .in_args = _in_args, \ + .out_args = _out_args, \ + .function = _function, \ + .flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_DEPRECATED + +#define GDBUS_EXPERIMENTAL_METHOD(_name, _in_args, _out_args, _function) \ + .name = _name, \ + .in_args = _in_args, \ + .out_args = _out_args, \ + .function = _function, \ + .flags = G_DBUS_METHOD_FLAG_EXPERIMENTAL + +#define GDBUS_EXPERIMENTAL_ASYNC_METHOD(_name, _in_args, _out_args, _function) \ + .name = _name, \ + .in_args = _in_args, \ + .out_args = _out_args, \ + .function = _function, \ + .flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_EXPERIMENTAL + +#define GDBUS_NOREPLY_METHOD(_name, _in_args, _out_args, _function) \ + .name = _name, \ + .in_args = _in_args, \ + .out_args = _out_args, \ + .function = _function, \ + .flags = G_DBUS_METHOD_FLAG_NOREPLY + +#define GDBUS_SIGNAL(_name, _args) \ + .name = _name, \ + .args = _args + +#define GDBUS_DEPRECATED_SIGNAL(_name, _args) \ + .name = _name, \ + .args = _args, \ + .flags = G_DBUS_SIGNAL_FLAG_DEPRECATED + +#define GDBUS_EXPERIMENTAL_SIGNAL(_name, _args) \ + .name = _name, \ + .args = _args, \ + .flags = G_DBUS_SIGNAL_FLAG_EXPERIMENTAL + +void g_dbus_set_flags(int flags); + +gboolean g_dbus_register_interface(DBusConnection *connection, + const char *path, const char *name, + const GDBusMethodTable *methods, + const GDBusSignalTable *signals, + const GDBusPropertyTable *properties, + void *user_data, + GDBusDestroyFunction destroy); +gboolean g_dbus_unregister_interface(DBusConnection *connection, + const char *path, const char *name); + +gboolean g_dbus_register_security(const GDBusSecurityTable *security); +gboolean g_dbus_unregister_security(const GDBusSecurityTable *security); + +void g_dbus_pending_success(DBusConnection *connection, + GDBusPendingReply pending); +void g_dbus_pending_error(DBusConnection *connection, + GDBusPendingReply pending, + const char *name, const char *format, ...) + __attribute__((format(printf, 4, 5))); +void g_dbus_pending_error_valist(DBusConnection *connection, + GDBusPendingReply pending, const char *name, + const char *format, va_list args); + +DBusMessage *g_dbus_create_error(DBusMessage *message, const char *name, + const char *format, ...) + __attribute__((format(printf, 3, 4))); +DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name, + const char *format, va_list args); +DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...); +DBusMessage *g_dbus_create_reply_valist(DBusMessage *message, + int type, va_list args); + +gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message); +gboolean g_dbus_send_message_with_reply(DBusConnection *connection, + DBusMessage *message, + DBusPendingCall **call, int timeout); +gboolean g_dbus_send_error(DBusConnection *connection, DBusMessage *message, + const char *name, const char *format, ...) + __attribute__((format(printf, 4, 5))); +gboolean g_dbus_send_error_valist(DBusConnection *connection, + DBusMessage *message, const char *name, + const char *format, va_list args); +gboolean g_dbus_send_reply(DBusConnection *connection, + DBusMessage *message, int type, ...); +gboolean g_dbus_send_reply_valist(DBusConnection *connection, + DBusMessage *message, int type, va_list args); + +gboolean g_dbus_emit_signal(DBusConnection *connection, + const char *path, const char *interface, + const char *name, int type, ...); +gboolean g_dbus_emit_signal_valist(DBusConnection *connection, + const char *path, const char *interface, + const char *name, int type, va_list args); + +guint g_dbus_add_service_watch(DBusConnection *connection, const char *name, + GDBusWatchFunction connect, + GDBusWatchFunction disconnect, + void *user_data, GDBusDestroyFunction destroy); +guint g_dbus_add_disconnect_watch(DBusConnection *connection, const char *name, + GDBusWatchFunction function, + void *user_data, GDBusDestroyFunction destroy); +guint g_dbus_add_signal_watch(DBusConnection *connection, + const char *sender, const char *path, + const char *interface, const char *member, + GDBusSignalFunction function, void *user_data, + GDBusDestroyFunction destroy); +guint g_dbus_add_properties_watch(DBusConnection *connection, + const char *sender, const char *path, + const char *interface, + GDBusSignalFunction function, void *user_data, + GDBusDestroyFunction destroy); +gboolean g_dbus_remove_watch(DBusConnection *connection, guint tag); +void g_dbus_remove_all_watches(DBusConnection *connection); + +void g_dbus_pending_property_success(GDBusPendingPropertySet id); +void g_dbus_pending_property_error_valist(GDBusPendingReply id, + const char *name, const char *format, va_list args); +void g_dbus_pending_property_error(GDBusPendingReply id, const char *name, + const char *format, ...); +void g_dbus_emit_property_changed(DBusConnection *connection, + const char *path, const char *interface, + const char *name); +gboolean g_dbus_get_properties(DBusConnection *connection, const char *path, + const char *interface, DBusMessageIter *iter); + +gboolean g_dbus_attach_object_manager(DBusConnection *connection); +gboolean g_dbus_detach_object_manager(DBusConnection *connection); + +typedef struct GDBusClient GDBusClient; +typedef struct GDBusProxy GDBusProxy; + +GDBusProxy *g_dbus_proxy_new(GDBusClient *client, const char *path, + const char *interface); + +GDBusProxy *g_dbus_proxy_ref(GDBusProxy *proxy); +void g_dbus_proxy_unref(GDBusProxy *proxy); + +const char *g_dbus_proxy_get_path(GDBusProxy *proxy); +const char *g_dbus_proxy_get_interface(GDBusProxy *proxy); + +gboolean g_dbus_proxy_get_property(GDBusProxy *proxy, const char *name, + DBusMessageIter *iter); + +gboolean g_dbus_proxy_refresh_property(GDBusProxy *proxy, const char *name); + +typedef void (* GDBusResultFunction) (const DBusError *error, void *user_data); + +gboolean g_dbus_proxy_set_property_basic(GDBusProxy *proxy, + const char *name, int type, const void *value, + GDBusResultFunction function, void *user_data, + GDBusDestroyFunction destroy); + +gboolean g_dbus_proxy_set_property_array(GDBusProxy *proxy, + const char *name, int type, const void *value, + size_t size, GDBusResultFunction function, + void *user_data, GDBusDestroyFunction destroy); + +typedef void (* GDBusSetupFunction) (DBusMessageIter *iter, void *user_data); +typedef void (* GDBusReturnFunction) (DBusMessage *message, void *user_data); + +gboolean g_dbus_proxy_method_call(GDBusProxy *proxy, const char *method, + GDBusSetupFunction setup, + GDBusReturnFunction function, void *user_data, + GDBusDestroyFunction destroy); + +typedef void (* GDBusClientFunction) (GDBusClient *client, void *user_data); +typedef void (* GDBusProxyFunction) (GDBusProxy *proxy, void *user_data); +typedef void (* GDBusPropertyFunction) (GDBusProxy *proxy, const char *name, + DBusMessageIter *iter, void *user_data); + +gboolean g_dbus_proxy_set_property_watch(GDBusProxy *proxy, + GDBusPropertyFunction function, void *user_data); + +gboolean g_dbus_proxy_set_removed_watch(GDBusProxy *proxy, + GDBusProxyFunction destroy, void *user_data); + +GDBusClient *g_dbus_client_new(DBusConnection *connection, + const char *service, const char *path); + +GDBusClient *g_dbus_client_ref(GDBusClient *client); +void g_dbus_client_unref(GDBusClient *client); + +gboolean g_dbus_client_set_connect_watch(GDBusClient *client, + GDBusWatchFunction function, void *user_data); +gboolean g_dbus_client_set_disconnect_watch(GDBusClient *client, + GDBusWatchFunction function, void *user_data); +gboolean g_dbus_client_set_signal_watch(GDBusClient *client, + GDBusMessageFunction function, void *user_data); +gboolean g_dbus_client_set_ready_watch(GDBusClient *client, + GDBusClientFunction ready, void *user_data); +gboolean g_dbus_client_set_proxy_handlers(GDBusClient *client, + GDBusProxyFunction proxy_added, + GDBusProxyFunction proxy_removed, + GDBusPropertyFunction property_changed, + void *user_data); + +#ifdef __cplusplus +} +#endif + +#endif /* __GDBUS_H */
diff --git a/neard/gdbus/mainloop.c b/neard/gdbus/mainloop.c new file mode 100644 index 0000000..3e88eac --- /dev/null +++ b/neard/gdbus/mainloop.c
@@ -0,0 +1,377 @@ +/* + * + * D-Bus helper library + * + * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> + * + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib.h> +#include <dbus/dbus.h> + +#include "gdbus.h" + +#define info(fmt...) +#define error(fmt...) +#define debug(fmt...) + +struct timeout_handler { + guint id; + DBusTimeout *timeout; +}; + +struct watch_info { + guint id; + DBusWatch *watch; + DBusConnection *conn; +}; + +struct disconnect_data { + GDBusWatchFunction function; + void *user_data; +}; + +static gboolean disconnected_signal(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct disconnect_data *dc_data = data; + + error("Got disconnected from the system message bus"); + + dc_data->function(conn, dc_data->user_data); + + dbus_connection_unref(conn); + + return TRUE; +} + +static gboolean message_dispatch(void *data) +{ + DBusConnection *conn = data; + + /* Dispatch messages */ + while (dbus_connection_dispatch(conn) == DBUS_DISPATCH_DATA_REMAINS); + + dbus_connection_unref(conn); + + return FALSE; +} + +static inline void queue_dispatch(DBusConnection *conn, + DBusDispatchStatus status) +{ + if (status == DBUS_DISPATCH_DATA_REMAINS) + g_idle_add(message_dispatch, dbus_connection_ref(conn)); +} + +static gboolean watch_func(GIOChannel *chan, GIOCondition cond, gpointer data) +{ + struct watch_info *info = data; + unsigned int flags = 0; + DBusDispatchStatus status; + DBusConnection *conn; + + if (cond & G_IO_IN) flags |= DBUS_WATCH_READABLE; + if (cond & G_IO_OUT) flags |= DBUS_WATCH_WRITABLE; + if (cond & G_IO_HUP) flags |= DBUS_WATCH_HANGUP; + if (cond & G_IO_ERR) flags |= DBUS_WATCH_ERROR; + + /* Protect connection from being destroyed by dbus_watch_handle */ + conn = dbus_connection_ref(info->conn); + + dbus_watch_handle(info->watch, flags); + + status = dbus_connection_get_dispatch_status(conn); + queue_dispatch(conn, status); + + dbus_connection_unref(conn); + + return TRUE; +} + +static void watch_info_free(void *data) +{ + struct watch_info *info = data; + + if (info->id > 0) { + g_source_remove(info->id); + info->id = 0; + } + + dbus_connection_unref(info->conn); + + g_free(info); +} + +static dbus_bool_t add_watch(DBusWatch *watch, void *data) +{ + DBusConnection *conn = data; + GIOCondition cond = G_IO_HUP | G_IO_ERR; + GIOChannel *chan; + struct watch_info *info; + unsigned int flags; + int fd; + + if (!dbus_watch_get_enabled(watch)) + return TRUE; + + info = g_new0(struct watch_info, 1); + + fd = dbus_watch_get_unix_fd(watch); + chan = g_io_channel_unix_new(fd); + + info->watch = watch; + info->conn = dbus_connection_ref(conn); + + dbus_watch_set_data(watch, info, watch_info_free); + + flags = dbus_watch_get_flags(watch); + + if (flags & DBUS_WATCH_READABLE) cond |= G_IO_IN; + if (flags & DBUS_WATCH_WRITABLE) cond |= G_IO_OUT; + + info->id = g_io_add_watch(chan, cond, watch_func, info); + + g_io_channel_unref(chan); + + return TRUE; +} + +static void remove_watch(DBusWatch *watch, void *data) +{ + if (dbus_watch_get_enabled(watch)) + return; + + /* will trigger watch_info_free() */ + dbus_watch_set_data(watch, NULL, NULL); +} + +static void watch_toggled(DBusWatch *watch, void *data) +{ + /* Because we just exit on OOM, enable/disable is + * no different from add/remove */ + if (dbus_watch_get_enabled(watch)) + add_watch(watch, data); + else + remove_watch(watch, data); +} + +static gboolean timeout_handler_dispatch(gpointer data) +{ + struct timeout_handler *handler = data; + + handler->id = 0; + + /* if not enabled should not be polled by the main loop */ + if (!dbus_timeout_get_enabled(handler->timeout)) + return FALSE; + + dbus_timeout_handle(handler->timeout); + + return FALSE; +} + +static void timeout_handler_free(void *data) +{ + struct timeout_handler *handler = data; + + if (handler->id > 0) { + g_source_remove(handler->id); + handler->id = 0; + } + + g_free(handler); +} + +static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data) +{ + int interval = dbus_timeout_get_interval(timeout); + struct timeout_handler *handler; + + if (!dbus_timeout_get_enabled(timeout)) + return TRUE; + + handler = g_new0(struct timeout_handler, 1); + + handler->timeout = timeout; + + dbus_timeout_set_data(timeout, handler, timeout_handler_free); + + handler->id = g_timeout_add(interval, timeout_handler_dispatch, + handler); + + return TRUE; +} + +static void remove_timeout(DBusTimeout *timeout, void *data) +{ + /* will trigger timeout_handler_free() */ + dbus_timeout_set_data(timeout, NULL, NULL); +} + +static void timeout_toggled(DBusTimeout *timeout, void *data) +{ + if (dbus_timeout_get_enabled(timeout)) + add_timeout(timeout, data); + else + remove_timeout(timeout, data); +} + +static void dispatch_status(DBusConnection *conn, + DBusDispatchStatus status, void *data) +{ + if (!dbus_connection_get_is_connected(conn)) + return; + + queue_dispatch(conn, status); +} + +static inline void setup_dbus_with_main_loop(DBusConnection *conn) +{ + dbus_connection_set_watch_functions(conn, add_watch, remove_watch, + watch_toggled, conn, NULL); + + dbus_connection_set_timeout_functions(conn, add_timeout, remove_timeout, + timeout_toggled, NULL, NULL); + + dbus_connection_set_dispatch_status_function(conn, dispatch_status, + NULL, NULL); +} + +static gboolean setup_bus(DBusConnection *conn, const char *name, + DBusError *error) +{ + gboolean result; + DBusDispatchStatus status; + + if (name != NULL) { + result = g_dbus_request_name(conn, name, error); + + if (error != NULL) { + if (dbus_error_is_set(error) == TRUE) + return FALSE; + } + + if (result == FALSE) + return FALSE; + } + + setup_dbus_with_main_loop(conn); + + status = dbus_connection_get_dispatch_status(conn); + queue_dispatch(conn, status); + + return TRUE; +} + +DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, + DBusError *error) +{ + DBusConnection *conn; + + conn = dbus_bus_get(type, error); + + if (error != NULL) { + if (dbus_error_is_set(error) == TRUE) + return NULL; + } + + if (conn == NULL) + return NULL; + + if (setup_bus(conn, name, error) == FALSE) { + dbus_connection_unref(conn); + return NULL; + } + + return conn; +} + +DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name, + DBusError *error) +{ + DBusConnection *conn; + + conn = dbus_bus_get_private(type, error); + + if (error != NULL) { + if (dbus_error_is_set(error) == TRUE) + return NULL; + } + + if (conn == NULL) + return NULL; + + if (setup_bus(conn, name, error) == FALSE) { + dbus_connection_unref(conn); + return NULL; + } + + return conn; +} + +gboolean g_dbus_request_name(DBusConnection *connection, const char *name, + DBusError *error) +{ + int result; + + result = dbus_bus_request_name(connection, name, + DBUS_NAME_FLAG_DO_NOT_QUEUE, error); + + if (error != NULL) { + if (dbus_error_is_set(error) == TRUE) + return FALSE; + } + + if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + if (error != NULL) + dbus_set_error(error, name, "Name already in use"); + + return FALSE; + } + + return TRUE; +} + +gboolean g_dbus_set_disconnect_function(DBusConnection *connection, + GDBusWatchFunction function, + void *user_data, DBusFreeFunction destroy) +{ + struct disconnect_data *dc_data; + + dc_data = g_new0(struct disconnect_data, 1); + + dc_data->function = function; + dc_data->user_data = user_data; + + dbus_connection_set_exit_on_disconnect(connection, FALSE); + + if (g_dbus_add_signal_watch(connection, NULL, NULL, + DBUS_INTERFACE_LOCAL, "Disconnected", + disconnected_signal, dc_data, g_free) == 0) { + error("Failed to add watch for D-Bus Disconnected signal"); + g_free(dc_data); + return FALSE; + } + + return TRUE; +}
diff --git a/neard/gdbus/object.c b/neard/gdbus/object.c new file mode 100644 index 0000000..4d5a64c --- /dev/null +++ b/neard/gdbus/object.c
@@ -0,0 +1,1818 @@ +/* + * + * D-Bus helper library + * + * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> + * + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <string.h> + +#include <glib.h> +#include <dbus/dbus.h> + +#include "gdbus.h" + +#define info(fmt...) +#define error(fmt...) +#define debug(fmt...) + +#define DBUS_INTERFACE_OBJECT_MANAGER "org.freedesktop.DBus.ObjectManager" + +#ifndef DBUS_ERROR_UNKNOWN_PROPERTY +#define DBUS_ERROR_UNKNOWN_PROPERTY "org.freedesktop.DBus.Error.UnknownProperty" +#endif + +#ifndef DBUS_ERROR_PROPERTY_READ_ONLY +#define DBUS_ERROR_PROPERTY_READ_ONLY "org.freedesktop.DBus.Error.PropertyReadOnly" +#endif + +struct generic_data { + unsigned int refcount; + DBusConnection *conn; + char *path; + GSList *interfaces; + GSList *objects; + GSList *added; + GSList *removed; + guint process_id; + gboolean pending_prop; + char *introspect; + struct generic_data *parent; +}; + +struct interface_data { + char *name; + const GDBusMethodTable *methods; + const GDBusSignalTable *signals; + const GDBusPropertyTable *properties; + GSList *pending_prop; + void *user_data; + GDBusDestroyFunction destroy; +}; + +struct security_data { + GDBusPendingReply pending; + DBusMessage *message; + const GDBusMethodTable *method; + void *iface_user_data; +}; + +struct property_data { + DBusConnection *conn; + GDBusPendingPropertySet id; + DBusMessage *message; +}; + +static int global_flags = 0; +static struct generic_data *root; +static GSList *pending = NULL; + +static gboolean process_changes(gpointer user_data); +static void process_properties_from_interface(struct generic_data *data, + struct interface_data *iface); +static void process_property_changes(struct generic_data *data); + +static void print_arguments(GString *gstr, const GDBusArgInfo *args, + const char *direction) +{ + for (; args && args->name; args++) { + g_string_append_printf(gstr, + "<arg name=\"%s\" type=\"%s\"", + args->name, args->signature); + + if (direction) + g_string_append_printf(gstr, + " direction=\"%s\"/>\n", direction); + else + g_string_append_printf(gstr, "/>\n"); + + } +} + +#define G_DBUS_ANNOTATE(name_, value_) \ + "<annotation name=\"org.freedesktop.DBus." name_ "\" " \ + "value=\"" value_ "\"/>" + +#define G_DBUS_ANNOTATE_DEPRECATED \ + G_DBUS_ANNOTATE("Deprecated", "true") + +#define G_DBUS_ANNOTATE_NOREPLY \ + G_DBUS_ANNOTATE("Method.NoReply", "true") + +static gboolean check_experimental(int flags, int flag) +{ + if (!(flags & flag)) + return FALSE; + + return !(global_flags & G_DBUS_FLAG_ENABLE_EXPERIMENTAL); +} + +static void generate_interface_xml(GString *gstr, struct interface_data *iface) +{ + const GDBusMethodTable *method; + const GDBusSignalTable *signal; + const GDBusPropertyTable *property; + + for (method = iface->methods; method && method->name; method++) { + if (check_experimental(method->flags, + G_DBUS_METHOD_FLAG_EXPERIMENTAL)) + continue; + + g_string_append_printf(gstr, "<method name=\"%s\">", + method->name); + print_arguments(gstr, method->in_args, "in"); + print_arguments(gstr, method->out_args, "out"); + + if (method->flags & G_DBUS_METHOD_FLAG_DEPRECATED) + g_string_append_printf(gstr, + G_DBUS_ANNOTATE_DEPRECATED); + + if (method->flags & G_DBUS_METHOD_FLAG_NOREPLY) + g_string_append_printf(gstr, G_DBUS_ANNOTATE_NOREPLY); + + g_string_append_printf(gstr, "</method>"); + } + + for (signal = iface->signals; signal && signal->name; signal++) { + if (check_experimental(signal->flags, + G_DBUS_SIGNAL_FLAG_EXPERIMENTAL)) + continue; + + g_string_append_printf(gstr, "<signal name=\"%s\">", + signal->name); + print_arguments(gstr, signal->args, NULL); + + if (signal->flags & G_DBUS_SIGNAL_FLAG_DEPRECATED) + g_string_append_printf(gstr, + G_DBUS_ANNOTATE_DEPRECATED); + + g_string_append_printf(gstr, "</signal>\n"); + } + + for (property = iface->properties; property && property->name; + property++) { + if (check_experimental(property->flags, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL)) + continue; + + g_string_append_printf(gstr, "<property name=\"%s\"" + " type=\"%s\" access=\"%s%s\">", + property->name, property->type, + property->get ? "read" : "", + property->set ? "write" : ""); + + if (property->flags & G_DBUS_PROPERTY_FLAG_DEPRECATED) + g_string_append_printf(gstr, + G_DBUS_ANNOTATE_DEPRECATED); + + g_string_append_printf(gstr, "</property>"); + } +} + +static void generate_introspection_xml(DBusConnection *conn, + struct generic_data *data, const char *path) +{ + GSList *list; + GString *gstr; + char **children; + int i; + + g_free(data->introspect); + + gstr = g_string_new(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE); + + g_string_append_printf(gstr, "<node>"); + + for (list = data->interfaces; list; list = list->next) { + struct interface_data *iface = list->data; + + g_string_append_printf(gstr, "<interface name=\"%s\">", + iface->name); + + generate_interface_xml(gstr, iface); + + g_string_append_printf(gstr, "</interface>"); + } + + if (!dbus_connection_list_registered(conn, path, &children)) + goto done; + + for (i = 0; children[i]; i++) + g_string_append_printf(gstr, "<node name=\"%s\"/>", + children[i]); + + dbus_free_string_array(children); + +done: + g_string_append_printf(gstr, "</node>"); + + data->introspect = g_string_free(gstr, FALSE); +} + +static DBusMessage *introspect(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct generic_data *data = user_data; + DBusMessage *reply; + + if (data->introspect == NULL) + generate_introspection_xml(connection, data, + dbus_message_get_path(message)); + + reply = dbus_message_new_method_return(message); + if (reply == NULL) + return NULL; + + dbus_message_append_args(reply, DBUS_TYPE_STRING, &data->introspect, + DBUS_TYPE_INVALID); + + return reply; +} + +static DBusHandlerResult process_message(DBusConnection *connection, + DBusMessage *message, const GDBusMethodTable *method, + void *iface_user_data) +{ + DBusMessage *reply; + + reply = method->function(connection, message, iface_user_data); + + if (method->flags & G_DBUS_METHOD_FLAG_NOREPLY) { + if (reply != NULL) + dbus_message_unref(reply); + return DBUS_HANDLER_RESULT_HANDLED; + } + + if (method->flags & G_DBUS_METHOD_FLAG_ASYNC) { + if (reply == NULL) + return DBUS_HANDLER_RESULT_HANDLED; + } + + if (reply == NULL) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + g_dbus_send_message(connection, reply); + + return DBUS_HANDLER_RESULT_HANDLED; +} + +static GDBusPendingReply next_pending = 1; +static GSList *pending_security = NULL; + +static const GDBusSecurityTable *security_table = NULL; + +void g_dbus_pending_success(DBusConnection *connection, + GDBusPendingReply pending) +{ + GSList *list; + + for (list = pending_security; list; list = list->next) { + struct security_data *secdata = list->data; + + if (secdata->pending != pending) + continue; + + pending_security = g_slist_remove(pending_security, secdata); + + process_message(connection, secdata->message, + secdata->method, secdata->iface_user_data); + + dbus_message_unref(secdata->message); + g_free(secdata); + return; + } +} + +void g_dbus_pending_error_valist(DBusConnection *connection, + GDBusPendingReply pending, const char *name, + const char *format, va_list args) +{ + GSList *list; + + for (list = pending_security; list; list = list->next) { + struct security_data *secdata = list->data; + + if (secdata->pending != pending) + continue; + + pending_security = g_slist_remove(pending_security, secdata); + + g_dbus_send_error_valist(connection, secdata->message, + name, format, args); + + dbus_message_unref(secdata->message); + g_free(secdata); + return; + } +} + +void g_dbus_pending_error(DBusConnection *connection, + GDBusPendingReply pending, + const char *name, const char *format, ...) +{ + va_list args; + + va_start(args, format); + + g_dbus_pending_error_valist(connection, pending, name, format, args); + + va_end(args); +} + +int polkit_check_authorization(DBusConnection *conn, + const char *action, gboolean interaction, + void (*function) (dbus_bool_t authorized, + void *user_data), + void *user_data, int timeout); + +struct builtin_security_data { + DBusConnection *conn; + GDBusPendingReply pending; +}; + +static void builtin_security_result(dbus_bool_t authorized, void *user_data) +{ + struct builtin_security_data *data = user_data; + + if (authorized == TRUE) + g_dbus_pending_success(data->conn, data->pending); + else + g_dbus_pending_error(data->conn, data->pending, + DBUS_ERROR_AUTH_FAILED, NULL); + + g_free(data); +} + +static void builtin_security_function(DBusConnection *conn, + const char *action, + gboolean interaction, + GDBusPendingReply pending) +{ + struct builtin_security_data *data; + + data = g_new0(struct builtin_security_data, 1); + data->conn = conn; + data->pending = pending; + + if (polkit_check_authorization(conn, action, interaction, + builtin_security_result, data, 30000) < 0) + g_dbus_pending_error(conn, pending, NULL, NULL); +} + +static gboolean check_privilege(DBusConnection *conn, DBusMessage *msg, + const GDBusMethodTable *method, void *iface_user_data) +{ + const GDBusSecurityTable *security; + + for (security = security_table; security && security->privilege; + security++) { + struct security_data *secdata; + gboolean interaction; + + if (security->privilege != method->privilege) + continue; + + secdata = g_new(struct security_data, 1); + secdata->pending = next_pending++; + secdata->message = dbus_message_ref(msg); + secdata->method = method; + secdata->iface_user_data = iface_user_data; + + pending_security = g_slist_prepend(pending_security, secdata); + + if (security->flags & G_DBUS_SECURITY_FLAG_ALLOW_INTERACTION) + interaction = TRUE; + else + interaction = FALSE; + + if (!(security->flags & G_DBUS_SECURITY_FLAG_BUILTIN) && + security->function) + security->function(conn, security->action, + interaction, secdata->pending); + else + builtin_security_function(conn, security->action, + interaction, secdata->pending); + + return TRUE; + } + + return FALSE; +} + +static GDBusPendingPropertySet next_pending_property = 1; +static GSList *pending_property_set; + +static struct property_data *remove_pending_property_data( + GDBusPendingPropertySet id) +{ + struct property_data *propdata; + GSList *l; + + for (l = pending_property_set; l != NULL; l = l->next) { + propdata = l->data; + if (propdata->id != id) + continue; + + break; + } + + if (l == NULL) + return NULL; + + pending_property_set = g_slist_delete_link(pending_property_set, l); + + return propdata; +} + +void g_dbus_pending_property_success(GDBusPendingPropertySet id) +{ + struct property_data *propdata; + + propdata = remove_pending_property_data(id); + if (propdata == NULL) + return; + + g_dbus_send_reply(propdata->conn, propdata->message, + DBUS_TYPE_INVALID); + dbus_message_unref(propdata->message); + g_free(propdata); +} + +void g_dbus_pending_property_error_valist(GDBusPendingReply id, + const char *name, const char *format, + va_list args) +{ + struct property_data *propdata; + + propdata = remove_pending_property_data(id); + if (propdata == NULL) + return; + + g_dbus_send_error_valist(propdata->conn, propdata->message, name, + format, args); + + dbus_message_unref(propdata->message); + g_free(propdata); +} + +void g_dbus_pending_property_error(GDBusPendingReply id, const char *name, + const char *format, ...) +{ + va_list args; + + va_start(args, format); + + g_dbus_pending_property_error_valist(id, name, format, args); + + va_end(args); +} + +static void reset_parent(gpointer data, gpointer user_data) +{ + struct generic_data *child = data; + struct generic_data *parent = user_data; + + child->parent = parent; +} + +static void append_property(struct interface_data *iface, + const GDBusPropertyTable *p, DBusMessageIter *dict) +{ + DBusMessageIter entry, value; + + dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, + &entry); + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &p->name); + dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, p->type, + &value); + + p->get(p, &value, iface->user_data); + + dbus_message_iter_close_container(&entry, &value); + dbus_message_iter_close_container(dict, &entry); +} + +static void append_properties(struct interface_data *data, + DBusMessageIter *iter) +{ + DBusMessageIter dict; + const GDBusPropertyTable *p; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); + + for (p = data->properties; p && p->name; p++) { + if (check_experimental(p->flags, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL)) + continue; + + if (p->get == NULL) + continue; + + if (p->exists != NULL && !p->exists(p, data->user_data)) + continue; + + append_property(data, p, &dict); + } + + dbus_message_iter_close_container(iter, &dict); +} + +static void append_interface(gpointer data, gpointer user_data) +{ + struct interface_data *iface = data; + DBusMessageIter *array = user_data; + DBusMessageIter entry; + + dbus_message_iter_open_container(array, DBUS_TYPE_DICT_ENTRY, NULL, + &entry); + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &iface->name); + append_properties(data, &entry); + dbus_message_iter_close_container(array, &entry); +} + +static void emit_interfaces_added(struct generic_data *data) +{ + DBusMessage *signal; + DBusMessageIter iter, array; + + if (root == NULL || data == root) + return; + + signal = dbus_message_new_signal(root->path, + DBUS_INTERFACE_OBJECT_MANAGER, + "InterfacesAdded"); + if (signal == NULL) + return; + + dbus_message_iter_init_append(signal, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, + &data->path); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &array); + + g_slist_foreach(data->added, append_interface, &array); + g_slist_free(data->added); + data->added = NULL; + + dbus_message_iter_close_container(&iter, &array); + + /* Use dbus_connection_send to avoid recursive calls to g_dbus_flush */ + dbus_connection_send(data->conn, signal, NULL); + dbus_message_unref(signal); +} + +static struct interface_data *find_interface(GSList *interfaces, + const char *name) +{ + GSList *list; + + if (name == NULL) + return NULL; + + for (list = interfaces; list; list = list->next) { + struct interface_data *iface = list->data; + if (!strcmp(name, iface->name)) + return iface; + } + + return NULL; +} + +static gboolean g_dbus_args_have_signature(const GDBusArgInfo *args, + DBusMessage *message) +{ + const char *sig = dbus_message_get_signature(message); + const char *p = NULL; + + for (; args && args->signature && *sig; args++) { + p = args->signature; + + for (; *sig && *p; sig++, p++) { + if (*p != *sig) + return FALSE; + } + } + + if (*sig || (p && *p) || (args && args->signature)) + return FALSE; + + return TRUE; +} + +static void add_pending(struct generic_data *data) +{ + if (data->process_id > 0) + return; + + data->process_id = g_idle_add(process_changes, data); + + pending = g_slist_append(pending, data); +} + +static gboolean remove_interface(struct generic_data *data, const char *name) +{ + struct interface_data *iface; + + iface = find_interface(data->interfaces, name); + if (iface == NULL) + return FALSE; + + process_properties_from_interface(data, iface); + + data->interfaces = g_slist_remove(data->interfaces, iface); + + if (iface->destroy) { + iface->destroy(iface->user_data); + iface->user_data = NULL; + } + + /* + * Interface being removed was just added, on the same mainloop + * iteration? Don't send any signal + */ + if (g_slist_find(data->added, iface)) { + data->added = g_slist_remove(data->added, iface); + g_free(iface->name); + g_free(iface); + return TRUE; + } + + if (data->parent == NULL) { + g_free(iface->name); + g_free(iface); + return TRUE; + } + + data->removed = g_slist_prepend(data->removed, iface->name); + g_free(iface); + + add_pending(data); + + return TRUE; +} + +static struct generic_data *invalidate_parent_data(DBusConnection *conn, + const char *child_path) +{ + struct generic_data *data = NULL, *child = NULL, *parent = NULL; + char *parent_path, *slash; + + parent_path = g_strdup(child_path); + slash = strrchr(parent_path, '/'); + if (slash == NULL) + goto done; + + if (slash == parent_path && parent_path[1] != '\0') + parent_path[1] = '\0'; + else + *slash = '\0'; + + if (!strlen(parent_path)) + goto done; + + if (dbus_connection_get_object_path_data(conn, parent_path, + (void *) &data) == FALSE) { + goto done; + } + + parent = invalidate_parent_data(conn, parent_path); + + if (data == NULL) { + data = parent; + if (data == NULL) + goto done; + } + + g_free(data->introspect); + data->introspect = NULL; + + if (!dbus_connection_get_object_path_data(conn, child_path, + (void *) &child)) + goto done; + + if (child == NULL || g_slist_find(data->objects, child) != NULL) + goto done; + + data->objects = g_slist_prepend(data->objects, child); + child->parent = data; + +done: + g_free(parent_path); + return data; +} + +static inline const GDBusPropertyTable *find_property(const GDBusPropertyTable *properties, + const char *name) +{ + const GDBusPropertyTable *p; + + for (p = properties; p && p->name; p++) { + if (strcmp(name, p->name) != 0) + continue; + + if (check_experimental(p->flags, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL)) + break; + + return p; + } + + return NULL; +} + +static DBusMessage *properties_get(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct generic_data *data = user_data; + struct interface_data *iface; + const GDBusPropertyTable *property; + const char *interface, *name; + DBusMessageIter iter, value; + DBusMessage *reply; + + if (!dbus_message_get_args(message, NULL, + DBUS_TYPE_STRING, &interface, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID)) + return NULL; + + iface = find_interface(data->interfaces, interface); + if (iface == NULL) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "No such interface '%s'", interface); + + property = find_property(iface->properties, name); + if (property == NULL) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "No such property '%s'", name); + + if (property->exists != NULL && + !property->exists(property, iface->user_data)) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "No such property '%s'", name); + + if (property->get == NULL) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "Property '%s' is not readable", name); + + reply = dbus_message_new_method_return(message); + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, + property->type, &value); + + if (!property->get(property, &value, iface->user_data)) { + dbus_message_unref(reply); + return NULL; + } + + dbus_message_iter_close_container(&iter, &value); + + return reply; +} + +static DBusMessage *properties_get_all(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct generic_data *data = user_data; + struct interface_data *iface; + const char *interface; + DBusMessageIter iter; + DBusMessage *reply; + + if (!dbus_message_get_args(message, NULL, + DBUS_TYPE_STRING, &interface, + DBUS_TYPE_INVALID)) + return NULL; + + iface = find_interface(data->interfaces, interface); + if (iface == NULL) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "No such interface '%s'", interface); + + reply = dbus_message_new_method_return(message); + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append(reply, &iter); + + append_properties(iface, &iter); + + return reply; +} + +static DBusMessage *properties_set(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct generic_data *data = user_data; + DBusMessageIter iter, sub; + struct interface_data *iface; + const GDBusPropertyTable *property; + const char *name, *interface; + struct property_data *propdata; + gboolean valid_signature; + char *signature; + + if (!dbus_message_iter_init(message, &iter)) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "No arguments given"); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "Invalid argument type: '%c'", + dbus_message_iter_get_arg_type(&iter)); + + dbus_message_iter_get_basic(&iter, &interface); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "Invalid argument type: '%c'", + dbus_message_iter_get_arg_type(&iter)); + + dbus_message_iter_get_basic(&iter, &name); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "Invalid argument type: '%c'", + dbus_message_iter_get_arg_type(&iter)); + + dbus_message_iter_recurse(&iter, &sub); + + iface = find_interface(data->interfaces, interface); + if (iface == NULL) + return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS, + "No such interface '%s'", interface); + + property = find_property(iface->properties, name); + if (property == NULL) + return g_dbus_create_error(message, + DBUS_ERROR_UNKNOWN_PROPERTY, + "No such property '%s'", name); + + if (property->set == NULL) + return g_dbus_create_error(message, + DBUS_ERROR_PROPERTY_READ_ONLY, + "Property '%s' is not writable", name); + + if (property->exists != NULL && + !property->exists(property, iface->user_data)) + return g_dbus_create_error(message, + DBUS_ERROR_UNKNOWN_PROPERTY, + "No such property '%s'", name); + + signature = dbus_message_iter_get_signature(&sub); + valid_signature = strcmp(signature, property->type) ? FALSE : TRUE; + dbus_free(signature); + if (!valid_signature) + return g_dbus_create_error(message, + DBUS_ERROR_INVALID_SIGNATURE, + "Invalid signature for '%s'", name); + + propdata = g_new(struct property_data, 1); + propdata->id = next_pending_property++; + propdata->message = dbus_message_ref(message); + propdata->conn = connection; + pending_property_set = g_slist_prepend(pending_property_set, propdata); + + property->set(property, &sub, propdata->id, iface->user_data); + + return NULL; +} + +static const GDBusMethodTable properties_methods[] = { + { GDBUS_METHOD("Get", + GDBUS_ARGS({ "interface", "s" }, { "name", "s" }), + GDBUS_ARGS({ "value", "v" }), + properties_get) }, + { GDBUS_ASYNC_METHOD("Set", + GDBUS_ARGS({ "interface", "s" }, { "name", "s" }, + { "value", "v" }), + NULL, + properties_set) }, + { GDBUS_METHOD("GetAll", + GDBUS_ARGS({ "interface", "s" }), + GDBUS_ARGS({ "properties", "a{sv}" }), + properties_get_all) }, + { } +}; + +static const GDBusSignalTable properties_signals[] = { + { GDBUS_SIGNAL("PropertiesChanged", + GDBUS_ARGS({ "interface", "s" }, + { "changed_properties", "a{sv}" }, + { "invalidated_properties", "as"})) }, + { } +}; + +static void append_name(gpointer data, gpointer user_data) +{ + char *name = data; + DBusMessageIter *iter = user_data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &name); +} + +static void emit_interfaces_removed(struct generic_data *data) +{ + DBusMessage *signal; + DBusMessageIter iter, array; + + if (root == NULL || data == root) + return; + + signal = dbus_message_new_signal(root->path, + DBUS_INTERFACE_OBJECT_MANAGER, + "InterfacesRemoved"); + if (signal == NULL) + return; + + dbus_message_iter_init_append(signal, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, + &data->path); + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &array); + + g_slist_foreach(data->removed, append_name, &array); + g_slist_free_full(data->removed, g_free); + data->removed = NULL; + + dbus_message_iter_close_container(&iter, &array); + + /* Use dbus_connection_send to avoid recursive calls to g_dbus_flush */ + dbus_connection_send(data->conn, signal, NULL); + dbus_message_unref(signal); +} + +static void remove_pending(struct generic_data *data) +{ + if (data->process_id > 0) { + g_source_remove(data->process_id); + data->process_id = 0; + } + + pending = g_slist_remove(pending, data); +} + +static gboolean process_changes(gpointer user_data) +{ + struct generic_data *data = user_data; + + remove_pending(data); + + if (data->added != NULL) + emit_interfaces_added(data); + + /* Flush pending properties */ + if (data->pending_prop == TRUE) + process_property_changes(data); + + if (data->removed != NULL) + emit_interfaces_removed(data); + + data->process_id = 0; + + return FALSE; +} + +static void generic_unregister(DBusConnection *connection, void *user_data) +{ + struct generic_data *data = user_data; + struct generic_data *parent = data->parent; + + if (parent != NULL) + parent->objects = g_slist_remove(parent->objects, data); + + if (data->process_id > 0) { + g_source_remove(data->process_id); + data->process_id = 0; + process_changes(data); + } + + g_slist_foreach(data->objects, reset_parent, data->parent); + g_slist_free(data->objects); + + dbus_connection_unref(data->conn); + g_free(data->introspect); + g_free(data->path); + g_free(data); +} + +static DBusHandlerResult generic_message(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct generic_data *data = user_data; + struct interface_data *iface; + const GDBusMethodTable *method; + const char *interface; + + interface = dbus_message_get_interface(message); + + iface = find_interface(data->interfaces, interface); + if (iface == NULL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + for (method = iface->methods; method && + method->name && method->function; method++) { + + if (dbus_message_is_method_call(message, iface->name, + method->name) == FALSE) + continue; + + if (check_experimental(method->flags, + G_DBUS_METHOD_FLAG_EXPERIMENTAL)) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (g_dbus_args_have_signature(method->in_args, + message) == FALSE) + continue; + + if (check_privilege(connection, message, method, + iface->user_data) == TRUE) + return DBUS_HANDLER_RESULT_HANDLED; + + return process_message(connection, message, method, + iface->user_data); + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static DBusObjectPathVTable generic_table = { + .unregister_function = generic_unregister, + .message_function = generic_message, +}; + +static const GDBusMethodTable introspect_methods[] = { + { GDBUS_METHOD("Introspect", NULL, + GDBUS_ARGS({ "xml", "s" }), introspect) }, + { } +}; + +static void append_interfaces(struct generic_data *data, DBusMessageIter *iter) +{ + DBusMessageIter array; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &array); + + g_slist_foreach(data->interfaces, append_interface, &array); + + dbus_message_iter_close_container(iter, &array); +} + +static void append_object(gpointer data, gpointer user_data) +{ + struct generic_data *child = data; + DBusMessageIter *array = user_data; + DBusMessageIter entry; + + dbus_message_iter_open_container(array, DBUS_TYPE_DICT_ENTRY, NULL, + &entry); + dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH, + &child->path); + append_interfaces(child, &entry); + dbus_message_iter_close_container(array, &entry); + + g_slist_foreach(child->objects, append_object, user_data); +} + +static DBusMessage *get_objects(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct generic_data *data = user_data; + DBusMessage *reply; + DBusMessageIter iter; + DBusMessageIter array; + + reply = dbus_message_new_method_return(message); + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append(reply, &iter); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_OBJECT_PATH_AS_STRING + DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, + &array); + + g_slist_foreach(data->objects, append_object, &array); + + dbus_message_iter_close_container(&iter, &array); + + return reply; +} + +static const GDBusMethodTable manager_methods[] = { + { GDBUS_METHOD("GetManagedObjects", NULL, + GDBUS_ARGS({ "objects", "a{oa{sa{sv}}}" }), get_objects) }, + { } +}; + +static const GDBusSignalTable manager_signals[] = { + { GDBUS_SIGNAL("InterfacesAdded", + GDBUS_ARGS({ "object", "o" }, + { "interfaces", "a{sa{sv}}" })) }, + { GDBUS_SIGNAL("InterfacesRemoved", + GDBUS_ARGS({ "object", "o" }, { "interfaces", "as" })) }, + { } +}; + +static gboolean add_interface(struct generic_data *data, + const char *name, + const GDBusMethodTable *methods, + const GDBusSignalTable *signals, + const GDBusPropertyTable *properties, + void *user_data, + GDBusDestroyFunction destroy) +{ + struct interface_data *iface; + const GDBusMethodTable *method; + const GDBusSignalTable *signal; + const GDBusPropertyTable *property; + + for (method = methods; method && method->name; method++) { + if (!check_experimental(method->flags, + G_DBUS_METHOD_FLAG_EXPERIMENTAL)) + goto done; + } + + for (signal = signals; signal && signal->name; signal++) { + if (!check_experimental(signal->flags, + G_DBUS_SIGNAL_FLAG_EXPERIMENTAL)) + goto done; + } + + for (property = properties; property && property->name; property++) { + if (!check_experimental(property->flags, + G_DBUS_PROPERTY_FLAG_EXPERIMENTAL)) + goto done; + } + + /* Nothing to register */ + return FALSE; + +done: + iface = g_new0(struct interface_data, 1); + iface->name = g_strdup(name); + iface->methods = methods; + iface->signals = signals; + iface->properties = properties; + iface->user_data = user_data; + iface->destroy = destroy; + + data->interfaces = g_slist_append(data->interfaces, iface); + if (data->parent == NULL) + return TRUE; + + data->added = g_slist_append(data->added, iface); + + add_pending(data); + + return TRUE; +} + +static struct generic_data *object_path_ref(DBusConnection *connection, + const char *path) +{ + struct generic_data *data; + + if (dbus_connection_get_object_path_data(connection, path, + (void *) &data) == TRUE) { + if (data != NULL) { + data->refcount++; + return data; + } + } + + data = g_new0(struct generic_data, 1); + data->conn = dbus_connection_ref(connection); + data->path = g_strdup(path); + data->refcount = 1; + + data->introspect = g_strdup(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE "<node></node>"); + + if (!dbus_connection_register_object_path(connection, path, + &generic_table, data)) { + dbus_connection_unref(data->conn); + g_free(data->path); + g_free(data->introspect); + g_free(data); + return NULL; + } + + invalidate_parent_data(connection, path); + + add_interface(data, DBUS_INTERFACE_INTROSPECTABLE, introspect_methods, + NULL, NULL, data, NULL); + + return data; +} + +static void object_path_unref(DBusConnection *connection, const char *path) +{ + struct generic_data *data = NULL; + + if (dbus_connection_get_object_path_data(connection, path, + (void *) &data) == FALSE) + return; + + if (data == NULL) + return; + + data->refcount--; + + if (data->refcount > 0) + return; + + remove_interface(data, DBUS_INTERFACE_INTROSPECTABLE); + remove_interface(data, DBUS_INTERFACE_PROPERTIES); + + invalidate_parent_data(data->conn, data->path); + + dbus_connection_unregister_object_path(data->conn, data->path); +} + +static gboolean check_signal(DBusConnection *conn, const char *path, + const char *interface, const char *name, + const GDBusArgInfo **args) +{ + struct generic_data *data = NULL; + struct interface_data *iface; + const GDBusSignalTable *signal; + + *args = NULL; + if (!dbus_connection_get_object_path_data(conn, path, + (void *) &data) || data == NULL) { + error("dbus_connection_emit_signal: path %s isn't registered", + path); + return FALSE; + } + + iface = find_interface(data->interfaces, interface); + if (iface == NULL) { + error("dbus_connection_emit_signal: %s does not implement %s", + path, interface); + return FALSE; + } + + for (signal = iface->signals; signal && signal->name; signal++) { + if (strcmp(signal->name, name) != 0) + continue; + + if (signal->flags & G_DBUS_SIGNAL_FLAG_EXPERIMENTAL) { + const char *env = g_getenv("GDBUS_EXPERIMENTAL"); + if (g_strcmp0(env, "1") != 0) + break; + } + + *args = signal->args; + return TRUE; + } + + error("No signal named %s on interface %s", name, interface); + return FALSE; +} + +gboolean g_dbus_register_interface(DBusConnection *connection, + const char *path, const char *name, + const GDBusMethodTable *methods, + const GDBusSignalTable *signals, + const GDBusPropertyTable *properties, + void *user_data, + GDBusDestroyFunction destroy) +{ + struct generic_data *data; + + data = object_path_ref(connection, path); + if (data == NULL) + return FALSE; + + if (find_interface(data->interfaces, name)) { + object_path_unref(connection, path); + return FALSE; + } + + if (!add_interface(data, name, methods, signals, properties, user_data, + destroy)) { + object_path_unref(connection, path); + return FALSE; + } + + if (properties != NULL && !find_interface(data->interfaces, + DBUS_INTERFACE_PROPERTIES)) + add_interface(data, DBUS_INTERFACE_PROPERTIES, + properties_methods, properties_signals, NULL, + data, NULL); + + g_free(data->introspect); + data->introspect = NULL; + + return TRUE; +} + +gboolean g_dbus_unregister_interface(DBusConnection *connection, + const char *path, const char *name) +{ + struct generic_data *data = NULL; + + if (path == NULL) + return FALSE; + + if (dbus_connection_get_object_path_data(connection, path, + (void *) &data) == FALSE) + return FALSE; + + if (data == NULL) + return FALSE; + + if (remove_interface(data, name) == FALSE) + return FALSE; + + g_free(data->introspect); + data->introspect = NULL; + + object_path_unref(connection, data->path); + + return TRUE; +} + +gboolean g_dbus_register_security(const GDBusSecurityTable *security) +{ + if (security_table != NULL) + return FALSE; + + security_table = security; + + return TRUE; +} + +gboolean g_dbus_unregister_security(const GDBusSecurityTable *security) +{ + security_table = NULL; + + return TRUE; +} + +DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name, + const char *format, va_list args) +{ + char str[1024]; + + vsnprintf(str, sizeof(str), format, args); + + return dbus_message_new_error(message, name, str); +} + +DBusMessage *g_dbus_create_error(DBusMessage *message, const char *name, + const char *format, ...) +{ + va_list args; + DBusMessage *reply; + + va_start(args, format); + + reply = g_dbus_create_error_valist(message, name, format, args); + + va_end(args); + + return reply; +} + +DBusMessage *g_dbus_create_reply_valist(DBusMessage *message, + int type, va_list args) +{ + DBusMessage *reply; + + reply = dbus_message_new_method_return(message); + if (reply == NULL) + return NULL; + + if (dbus_message_append_args_valist(reply, type, args) == FALSE) { + dbus_message_unref(reply); + return NULL; + } + + return reply; +} + +DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...) +{ + va_list args; + DBusMessage *reply; + + va_start(args, type); + + reply = g_dbus_create_reply_valist(message, type, args); + + va_end(args); + + return reply; +} + +static void g_dbus_flush(DBusConnection *connection) +{ + GSList *l; + + for (l = pending; l;) { + struct generic_data *data = l->data; + + l = l->next; + if (data->conn != connection) + continue; + + process_changes(data); + } +} + +gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message) +{ + dbus_bool_t result = FALSE; + + if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL) + dbus_message_set_no_reply(message, TRUE); + else if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL) { + const char *path = dbus_message_get_path(message); + const char *interface = dbus_message_get_interface(message); + const char *name = dbus_message_get_member(message); + const GDBusArgInfo *args; + + if (!check_signal(connection, path, interface, name, &args)) + goto out; + } + + /* Flush pending signal to guarantee message order */ + g_dbus_flush(connection); + + result = dbus_connection_send(connection, message, NULL); + +out: + dbus_message_unref(message); + + return result; +} + +gboolean g_dbus_send_message_with_reply(DBusConnection *connection, + DBusMessage *message, + DBusPendingCall **call, int timeout) +{ + dbus_bool_t ret; + + /* Flush pending signal to guarantee message order */ + g_dbus_flush(connection); + + ret = dbus_connection_send_with_reply(connection, message, call, + timeout); + + if (ret == TRUE && call != NULL && *call == NULL) { + error("Unable to send message (passing fd blocked?)"); + return FALSE; + } + + return ret; +} + +gboolean g_dbus_send_error_valist(DBusConnection *connection, + DBusMessage *message, const char *name, + const char *format, va_list args) +{ + DBusMessage *error; + char str[1024]; + + vsnprintf(str, sizeof(str), format, args); + + error = dbus_message_new_error(message, name, str); + if (error == NULL) + return FALSE; + + return g_dbus_send_message(connection, error); +} + +gboolean g_dbus_send_error(DBusConnection *connection, DBusMessage *message, + const char *name, const char *format, ...) +{ + va_list args; + gboolean result; + + va_start(args, format); + + result = g_dbus_send_error_valist(connection, message, name, + format, args); + + va_end(args); + + return result; +} + +gboolean g_dbus_send_reply_valist(DBusConnection *connection, + DBusMessage *message, int type, va_list args) +{ + DBusMessage *reply; + + reply = dbus_message_new_method_return(message); + if (reply == NULL) + return FALSE; + + if (dbus_message_append_args_valist(reply, type, args) == FALSE) { + dbus_message_unref(reply); + return FALSE; + } + + return g_dbus_send_message(connection, reply); +} + +gboolean g_dbus_send_reply(DBusConnection *connection, + DBusMessage *message, int type, ...) +{ + va_list args; + gboolean result; + + va_start(args, type); + + result = g_dbus_send_reply_valist(connection, message, type, args); + + va_end(args); + + return result; +} + +gboolean g_dbus_emit_signal(DBusConnection *connection, + const char *path, const char *interface, + const char *name, int type, ...) +{ + va_list args; + gboolean result; + + va_start(args, type); + + result = g_dbus_emit_signal_valist(connection, path, interface, + name, type, args); + + va_end(args); + + return result; +} + +gboolean g_dbus_emit_signal_valist(DBusConnection *connection, + const char *path, const char *interface, + const char *name, int type, va_list args) +{ + DBusMessage *signal; + dbus_bool_t ret; + const GDBusArgInfo *args_info; + + if (!check_signal(connection, path, interface, name, &args_info)) + return FALSE; + + signal = dbus_message_new_signal(path, interface, name); + if (signal == NULL) { + error("Unable to allocate new %s.%s signal", interface, name); + return FALSE; + } + + ret = dbus_message_append_args_valist(signal, type, args); + if (!ret) + goto fail; + + if (g_dbus_args_have_signature(args_info, signal) == FALSE) { + error("%s.%s: got unexpected signature '%s'", interface, name, + dbus_message_get_signature(signal)); + ret = FALSE; + goto fail; + } + + return g_dbus_send_message(connection, signal); + +fail: + dbus_message_unref(signal); + + return ret; +} + +static void process_properties_from_interface(struct generic_data *data, + struct interface_data *iface) +{ + GSList *l; + DBusMessage *signal; + DBusMessageIter iter, dict, array; + GSList *invalidated; + + data->pending_prop = FALSE; + + if (iface->pending_prop == NULL) + return; + + signal = dbus_message_new_signal(data->path, + DBUS_INTERFACE_PROPERTIES, "PropertiesChanged"); + if (signal == NULL) { + error("Unable to allocate new " DBUS_INTERFACE_PROPERTIES + ".PropertiesChanged signal"); + return; + } + + iface->pending_prop = g_slist_reverse(iface->pending_prop); + + dbus_message_iter_init_append(signal, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &iface->name); + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); + + invalidated = NULL; + + for (l = iface->pending_prop; l != NULL; l = l->next) { + GDBusPropertyTable *p = l->data; + + if (p->get == NULL) + continue; + + if (p->exists != NULL && !p->exists(p, iface->user_data)) { + invalidated = g_slist_prepend(invalidated, p); + continue; + } + + append_property(iface, p, &dict); + } + + dbus_message_iter_close_container(&iter, &dict); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &array); + for (l = invalidated; l != NULL; l = g_slist_next(l)) { + GDBusPropertyTable *p = l->data; + + dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, + &p->name); + } + g_slist_free(invalidated); + dbus_message_iter_close_container(&iter, &array); + + g_slist_free(iface->pending_prop); + iface->pending_prop = NULL; + + /* Use dbus_connection_send to avoid recursive calls to g_dbus_flush */ + dbus_connection_send(data->conn, signal, NULL); + dbus_message_unref(signal); +} + +static void process_property_changes(struct generic_data *data) +{ + GSList *l; + + for (l = data->interfaces; l != NULL; l = l->next) { + struct interface_data *iface = l->data; + + process_properties_from_interface(data, iface); + } +} + +void g_dbus_emit_property_changed(DBusConnection *connection, + const char *path, const char *interface, + const char *name) +{ + const GDBusPropertyTable *property; + struct generic_data *data; + struct interface_data *iface; + + if (path == NULL) + return; + + if (!dbus_connection_get_object_path_data(connection, path, + (void **) &data) || data == NULL) + return; + + iface = find_interface(data->interfaces, interface); + if (iface == NULL) + return; + + /* + * If ObjectManager is attached, don't emit property changed if + * interface is not yet published + */ + if (root && g_slist_find(data->added, iface)) + return; + + property = find_property(iface->properties, name); + if (property == NULL) { + error("Could not find property %s in %p", name, + iface->properties); + return; + } + + if (g_slist_find(iface->pending_prop, (void *) property) != NULL) + return; + + data->pending_prop = TRUE; + iface->pending_prop = g_slist_prepend(iface->pending_prop, + (void *) property); + + add_pending(data); +} + +gboolean g_dbus_get_properties(DBusConnection *connection, const char *path, + const char *interface, DBusMessageIter *iter) +{ + struct generic_data *data; + struct interface_data *iface; + + if (path == NULL) + return FALSE; + + if (!dbus_connection_get_object_path_data(connection, path, + (void **) &data) || data == NULL) + return FALSE; + + iface = find_interface(data->interfaces, interface); + if (iface == NULL) + return FALSE; + + append_properties(iface, iter); + + return TRUE; +} + +gboolean g_dbus_attach_object_manager(DBusConnection *connection) +{ + struct generic_data *data; + + data = object_path_ref(connection, "/"); + if (data == NULL) + return FALSE; + + add_interface(data, DBUS_INTERFACE_OBJECT_MANAGER, + manager_methods, manager_signals, + NULL, data, NULL); + root = data; + + return TRUE; +} + +gboolean g_dbus_detach_object_manager(DBusConnection *connection) +{ + if (!g_dbus_unregister_interface(connection, "/", + DBUS_INTERFACE_OBJECT_MANAGER)) + return FALSE; + + root = NULL; + + return TRUE; +} + +void g_dbus_set_flags(int flags) +{ + global_flags = flags; +}
diff --git a/neard/gdbus/polkit.c b/neard/gdbus/polkit.c new file mode 100644 index 0000000..9e95fa3 --- /dev/null +++ b/neard/gdbus/polkit.c
@@ -0,0 +1,202 @@ +/* + * + * D-Bus helper library + * + * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> + * + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <errno.h> + +#include <dbus/dbus.h> + +#include <glib.h> + +int polkit_check_authorization(DBusConnection *conn, + const char *action, gboolean interaction, + void (*function) (dbus_bool_t authorized, + void *user_data), + void *user_data, int timeout); + +static void add_dict_with_string_value(DBusMessageIter *iter, + const char *key, const char *str) +{ + DBusMessageIter dict, entry, value; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); + dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, + NULL, &entry); + + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); + + dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, + DBUS_TYPE_STRING_AS_STRING, &value); + dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &str); + dbus_message_iter_close_container(&entry, &value); + + dbus_message_iter_close_container(&dict, &entry); + dbus_message_iter_close_container(iter, &dict); +} + +static void add_empty_string_dict(DBusMessageIter *iter) +{ + DBusMessageIter dict; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_STRING_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); + + dbus_message_iter_close_container(iter, &dict); +} + +static void add_arguments(DBusConnection *conn, DBusMessageIter *iter, + const char *action, dbus_uint32_t flags) +{ + const char *busname = dbus_bus_get_unique_name(conn); + const char *kind = "system-bus-name"; + const char *cancel = ""; + DBusMessageIter subject; + + dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, + NULL, &subject); + dbus_message_iter_append_basic(&subject, DBUS_TYPE_STRING, &kind); + add_dict_with_string_value(&subject, "name", busname); + dbus_message_iter_close_container(iter, &subject); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &action); + add_empty_string_dict(iter); + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &flags); + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &cancel); +} + +static dbus_bool_t parse_result(DBusMessageIter *iter) +{ + DBusMessageIter result; + dbus_bool_t authorized, challenge; + + dbus_message_iter_recurse(iter, &result); + + dbus_message_iter_get_basic(&result, &authorized); + dbus_message_iter_get_basic(&result, &challenge); + + return authorized; +} + +struct authorization_data { + void (*function) (dbus_bool_t authorized, void *user_data); + void *user_data; +}; + +static void authorization_reply(DBusPendingCall *call, void *user_data) +{ + struct authorization_data *data = user_data; + DBusMessage *reply; + DBusMessageIter iter; + dbus_bool_t authorized = FALSE; + + reply = dbus_pending_call_steal_reply(call); + + if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) + goto done; + + if (dbus_message_has_signature(reply, "(bba{ss})") == FALSE) + goto done; + + dbus_message_iter_init(reply, &iter); + + authorized = parse_result(&iter); + +done: + if (data->function != NULL) + data->function(authorized, data->user_data); + + dbus_message_unref(reply); + + dbus_pending_call_unref(call); +} + +#define AUTHORITY_DBUS "org.freedesktop.PolicyKit1" +#define AUTHORITY_INTF "org.freedesktop.PolicyKit1.Authority" +#define AUTHORITY_PATH "/org/freedesktop/PolicyKit1/Authority" + +int polkit_check_authorization(DBusConnection *conn, + const char *action, gboolean interaction, + void (*function) (dbus_bool_t authorized, + void *user_data), + void *user_data, int timeout) +{ + struct authorization_data *data; + DBusMessage *msg; + DBusMessageIter iter; + DBusPendingCall *call; + dbus_uint32_t flags = 0x00000000; + + if (conn == NULL) + return -EINVAL; + + data = dbus_malloc0(sizeof(*data)); + if (data == NULL) + return -ENOMEM; + + msg = dbus_message_new_method_call(AUTHORITY_DBUS, AUTHORITY_PATH, + AUTHORITY_INTF, "CheckAuthorization"); + if (msg == NULL) { + dbus_free(data); + return -ENOMEM; + } + + if (interaction == TRUE) + flags |= 0x00000001; + + if (action == NULL) + action = "org.freedesktop.policykit.exec"; + + dbus_message_iter_init_append(msg, &iter); + add_arguments(conn, &iter, action, flags); + + if (dbus_connection_send_with_reply(conn, msg, + &call, timeout) == FALSE) { + dbus_message_unref(msg); + dbus_free(data); + return -EIO; + } + + if (call == NULL) { + dbus_message_unref(msg); + dbus_free(data); + return -EIO; + } + + data->function = function; + data->user_data = user_data; + + dbus_pending_call_set_notify(call, authorization_reply, + data, dbus_free); + + dbus_message_unref(msg); + + return 0; +}
diff --git a/neard/gdbus/watch.c b/neard/gdbus/watch.c new file mode 100644 index 0000000..0d0054c --- /dev/null +++ b/neard/gdbus/watch.c
@@ -0,0 +1,817 @@ +/* + * + * D-Bus helper library + * + * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org> + * + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <string.h> + +#include <glib.h> +#include <dbus/dbus.h> + +#include "gdbus.h" + +#define info(fmt...) +#define error(fmt...) +#define debug(fmt...) + +static DBusHandlerResult message_filter(DBusConnection *connection, + DBusMessage *message, void *user_data); + +static guint listener_id = 0; +static GSList *listeners = NULL; + +struct service_data { + DBusConnection *conn; + DBusPendingCall *call; + char *name; + const char *owner; + guint id; + struct filter_callback *callback; +}; + +struct filter_callback { + GDBusWatchFunction conn_func; + GDBusWatchFunction disc_func; + GDBusSignalFunction signal_func; + GDBusDestroyFunction destroy_func; + struct service_data *data; + void *user_data; + guint id; +}; + +struct filter_data { + DBusConnection *connection; + DBusHandleMessageFunction handle_func; + char *name; + char *owner; + char *path; + char *interface; + char *member; + char *argument; + GSList *callbacks; + GSList *processed; + guint name_watch; + gboolean lock; + gboolean registered; +}; + +static struct filter_data *filter_data_find_match(DBusConnection *connection, + const char *name, + const char *owner, + const char *path, + const char *interface, + const char *member, + const char *argument) +{ + GSList *current; + + for (current = listeners; + current != NULL; current = current->next) { + struct filter_data *data = current->data; + + if (connection != data->connection) + continue; + + if (g_strcmp0(name, data->name) != 0) + continue; + + if (g_strcmp0(owner, data->owner) != 0) + continue; + + if (g_strcmp0(path, data->path) != 0) + continue; + + if (g_strcmp0(interface, data->interface) != 0) + continue; + + if (g_strcmp0(member, data->member) != 0) + continue; + + if (g_strcmp0(argument, data->argument) != 0) + continue; + + return data; + } + + return NULL; +} + +static struct filter_data *filter_data_find(DBusConnection *connection) +{ + GSList *current; + + for (current = listeners; + current != NULL; current = current->next) { + struct filter_data *data = current->data; + + if (connection != data->connection) + continue; + + return data; + } + + return NULL; +} + +static void format_rule(struct filter_data *data, char *rule, size_t size) +{ + const char *sender; + int offset; + + offset = snprintf(rule, size, "type='signal'"); + sender = data->name ? : data->owner; + + if (sender) + offset += snprintf(rule + offset, size - offset, + ",sender='%s'", sender); + if (data->path) + offset += snprintf(rule + offset, size - offset, + ",path='%s'", data->path); + if (data->interface) + offset += snprintf(rule + offset, size - offset, + ",interface='%s'", data->interface); + if (data->member) + offset += snprintf(rule + offset, size - offset, + ",member='%s'", data->member); + if (data->argument) + snprintf(rule + offset, size - offset, + ",arg0='%s'", data->argument); +} + +static gboolean add_match(struct filter_data *data, + DBusHandleMessageFunction filter) +{ + DBusError err; + char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; + + format_rule(data, rule, sizeof(rule)); + dbus_error_init(&err); + + dbus_bus_add_match(data->connection, rule, &err); + if (dbus_error_is_set(&err)) { + error("Adding match rule \"%s\" failed: %s", rule, + err.message); + dbus_error_free(&err); + return FALSE; + } + + data->handle_func = filter; + data->registered = TRUE; + + return TRUE; +} + +static gboolean remove_match(struct filter_data *data) +{ + DBusError err; + char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; + + format_rule(data, rule, sizeof(rule)); + + dbus_error_init(&err); + + dbus_bus_remove_match(data->connection, rule, &err); + if (dbus_error_is_set(&err)) { + error("Removing owner match rule for %s failed: %s", + rule, err.message); + dbus_error_free(&err); + return FALSE; + } + + return TRUE; +} + +static struct filter_data *filter_data_get(DBusConnection *connection, + DBusHandleMessageFunction filter, + const char *sender, + const char *path, + const char *interface, + const char *member, + const char *argument) +{ + struct filter_data *data; + const char *name = NULL, *owner = NULL; + + if (filter_data_find(connection) == NULL) { + if (!dbus_connection_add_filter(connection, + message_filter, NULL, NULL)) { + error("dbus_connection_add_filter() failed"); + return NULL; + } + } + + if (sender == NULL) + goto proceed; + + if (sender[0] == ':') + owner = sender; + else + name = sender; + +proceed: + data = filter_data_find_match(connection, name, owner, path, + interface, member, argument); + if (data) + return data; + + data = g_new0(struct filter_data, 1); + + data->connection = dbus_connection_ref(connection); + data->name = g_strdup(name); + data->owner = g_strdup(owner); + data->path = g_strdup(path); + data->interface = g_strdup(interface); + data->member = g_strdup(member); + data->argument = g_strdup(argument); + + if (!add_match(data, filter)) { + g_free(data); + return NULL; + } + + listeners = g_slist_append(listeners, data); + + return data; +} + +static struct filter_callback *filter_data_find_callback( + struct filter_data *data, + guint id) +{ + GSList *l; + + for (l = data->callbacks; l; l = l->next) { + struct filter_callback *cb = l->data; + if (cb->id == id) + return cb; + } + for (l = data->processed; l; l = l->next) { + struct filter_callback *cb = l->data; + if (cb->id == id) + return cb; + } + + return NULL; +} + +static void filter_data_free(struct filter_data *data) +{ + GSList *l; + + /* Remove filter if there are no listeners left for the connection */ + if (filter_data_find(data->connection) == NULL) + dbus_connection_remove_filter(data->connection, message_filter, + NULL); + + for (l = data->callbacks; l != NULL; l = l->next) + g_free(l->data); + + g_slist_free(data->callbacks); + g_dbus_remove_watch(data->connection, data->name_watch); + g_free(data->name); + g_free(data->owner); + g_free(data->path); + g_free(data->interface); + g_free(data->member); + g_free(data->argument); + dbus_connection_unref(data->connection); + g_free(data); +} + +static void filter_data_call_and_free(struct filter_data *data) +{ + GSList *l; + + for (l = data->callbacks; l != NULL; l = l->next) { + struct filter_callback *cb = l->data; + if (cb->disc_func) + cb->disc_func(data->connection, cb->user_data); + if (cb->destroy_func) + cb->destroy_func(cb->user_data); + g_free(cb); + } + + filter_data_free(data); +} + +static struct filter_callback *filter_data_add_callback( + struct filter_data *data, + GDBusWatchFunction connect, + GDBusWatchFunction disconnect, + GDBusSignalFunction signal, + GDBusDestroyFunction destroy, + void *user_data) +{ + struct filter_callback *cb = NULL; + + cb = g_new0(struct filter_callback, 1); + + cb->conn_func = connect; + cb->disc_func = disconnect; + cb->signal_func = signal; + cb->destroy_func = destroy; + cb->user_data = user_data; + cb->id = ++listener_id; + + if (data->lock) + data->processed = g_slist_append(data->processed, cb); + else + data->callbacks = g_slist_append(data->callbacks, cb); + + return cb; +} + +static void service_data_free(struct service_data *data) +{ + struct filter_callback *callback = data->callback; + + dbus_connection_unref(data->conn); + + if (data->call) + dbus_pending_call_unref(data->call); + + if (data->id) + g_source_remove(data->id); + + g_free(data->name); + g_free(data); + + callback->data = NULL; +} + +/* Returns TRUE if data is freed */ +static gboolean filter_data_remove_callback(struct filter_data *data, + struct filter_callback *cb) +{ + data->callbacks = g_slist_remove(data->callbacks, cb); + data->processed = g_slist_remove(data->processed, cb); + + /* Cancel pending operations */ + if (cb->data) { + if (cb->data->call) + dbus_pending_call_cancel(cb->data->call); + service_data_free(cb->data); + } + + if (cb->destroy_func) + cb->destroy_func(cb->user_data); + + g_free(cb); + + /* Don't remove the filter if other callbacks exist or data is lock + * processing callbacks */ + if (data->callbacks || data->lock) + return FALSE; + + if (data->registered && !remove_match(data)) + return FALSE; + + listeners = g_slist_remove(listeners, data); + filter_data_free(data); + + return TRUE; +} + +static DBusHandlerResult signal_filter(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct filter_data *data = user_data; + struct filter_callback *cb; + + while (data->callbacks) { + cb = data->callbacks->data; + + if (cb->signal_func && !cb->signal_func(connection, message, + cb->user_data)) { + if (filter_data_remove_callback(data, cb)) + break; + + continue; + } + + /* Check if the watch was removed/freed by the callback + * function */ + if (!g_slist_find(data->callbacks, cb)) + continue; + + data->callbacks = g_slist_remove(data->callbacks, cb); + data->processed = g_slist_append(data->processed, cb); + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static void update_name_cache(const char *name, const char *owner) +{ + GSList *l; + + for (l = listeners; l != NULL; l = l->next) { + struct filter_data *data = l->data; + + if (g_strcmp0(data->name, name) != 0) + continue; + + g_free(data->owner); + data->owner = g_strdup(owner); + } +} + +static const char *check_name_cache(const char *name) +{ + GSList *l; + + for (l = listeners; l != NULL; l = l->next) { + struct filter_data *data = l->data; + + if (g_strcmp0(data->name, name) != 0) + continue; + + return data->owner; + } + + return NULL; +} + +static DBusHandlerResult service_filter(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct filter_data *data = user_data; + struct filter_callback *cb; + char *name, *old, *new; + + if (!dbus_message_get_args(message, NULL, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_STRING, &old, + DBUS_TYPE_STRING, &new, + DBUS_TYPE_INVALID)) { + error("Invalid arguments for NameOwnerChanged signal"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + update_name_cache(name, new); + + while (data->callbacks) { + cb = data->callbacks->data; + + if (*new == '\0') { + if (cb->disc_func) + cb->disc_func(connection, cb->user_data); + } else { + if (cb->conn_func) + cb->conn_func(connection, cb->user_data); + } + + /* Check if the watch was removed/freed by the callback + * function */ + if (!g_slist_find(data->callbacks, cb)) + continue; + + /* Only auto remove if it is a bus name watch */ + if (data->argument[0] == ':' && + (cb->conn_func == NULL || cb->disc_func == NULL)) { + if (filter_data_remove_callback(data, cb)) + break; + + continue; + } + + data->callbacks = g_slist_remove(data->callbacks, cb); + data->processed = g_slist_append(data->processed, cb); + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + + +static DBusHandlerResult message_filter(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + struct filter_data *data; + const char *sender, *path, *iface, *member, *arg = NULL; + GSList *current, *delete_listener = NULL; + + /* Only filter signals */ + if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + sender = dbus_message_get_sender(message); + path = dbus_message_get_path(message); + iface = dbus_message_get_interface(message); + member = dbus_message_get_member(message); + dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID); + + /* Sender is always the owner */ + if (sender == NULL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + for (current = listeners; current != NULL; current = current->next) { + data = current->data; + + if (connection != data->connection) + continue; + + if (data->owner && g_str_equal(sender, data->owner) == FALSE) + continue; + + if (data->path && g_str_equal(path, data->path) == FALSE) + continue; + + if (data->interface && g_str_equal(iface, + data->interface) == FALSE) + continue; + + if (data->member && g_str_equal(member, data->member) == FALSE) + continue; + + if (data->argument && g_str_equal(arg, + data->argument) == FALSE) + continue; + + if (data->handle_func) { + data->lock = TRUE; + + data->handle_func(connection, message, data); + + data->callbacks = data->processed; + data->processed = NULL; + data->lock = FALSE; + } + + if (!data->callbacks) + delete_listener = g_slist_prepend(delete_listener, + current); + } + + if (delete_listener == NULL) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + for (current = delete_listener; current != NULL; + current = delete_listener->next) { + GSList *l = current->data; + + data = l->data; + + /* Has any other callback added callbacks back to this data? */ + if (data->callbacks != NULL) + continue; + + remove_match(data); + listeners = g_slist_delete_link(listeners, l); + + filter_data_free(data); + } + + g_slist_free(delete_listener); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static gboolean update_service(void *user_data) +{ + struct service_data *data = user_data; + struct filter_callback *cb = data->callback; + DBusConnection *conn; + + conn = dbus_connection_ref(data->conn); + service_data_free(data); + + if (cb->conn_func) + cb->conn_func(conn, cb->user_data); + + dbus_connection_unref(conn); + + return FALSE; +} + +static void service_reply(DBusPendingCall *call, void *user_data) +{ + struct service_data *data = user_data; + DBusMessage *reply; + DBusError err; + + reply = dbus_pending_call_steal_reply(call); + if (reply == NULL) + return; + + dbus_error_init(&err); + + if (dbus_set_error_from_message(&err, reply)) + goto fail; + + if (dbus_message_get_args(reply, &err, + DBUS_TYPE_STRING, &data->owner, + DBUS_TYPE_INVALID) == FALSE) + goto fail; + + update_service(data); + + goto done; + +fail: + error("%s", err.message); + dbus_error_free(&err); + service_data_free(data); +done: + dbus_message_unref(reply); +} + +static void check_service(DBusConnection *connection, + const char *name, + struct filter_callback *callback) +{ + DBusMessage *message; + struct service_data *data; + + data = g_try_malloc0(sizeof(*data)); + if (data == NULL) { + error("Can't allocate data structure"); + return; + } + + data->conn = dbus_connection_ref(connection); + data->name = g_strdup(name); + data->callback = callback; + callback->data = data; + + data->owner = check_name_cache(name); + if (data->owner != NULL) { + data->id = g_idle_add(update_service, data); + return; + } + + message = dbus_message_new_method_call(DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetNameOwner"); + if (message == NULL) { + error("Can't allocate new message"); + g_free(data); + return; + } + + dbus_message_append_args(message, DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID); + + if (dbus_connection_send_with_reply(connection, message, + &data->call, -1) == FALSE) { + error("Failed to execute method call"); + g_free(data); + goto done; + } + + if (data->call == NULL) { + error("D-Bus connection not available"); + g_free(data); + goto done; + } + + dbus_pending_call_set_notify(data->call, service_reply, data, NULL); + +done: + dbus_message_unref(message); +} + +guint g_dbus_add_service_watch(DBusConnection *connection, const char *name, + GDBusWatchFunction connect, + GDBusWatchFunction disconnect, + void *user_data, GDBusDestroyFunction destroy) +{ + struct filter_data *data; + struct filter_callback *cb; + + if (name == NULL) + return 0; + + data = filter_data_get(connection, service_filter, + DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, "NameOwnerChanged", + name); + if (data == NULL) + return 0; + + cb = filter_data_add_callback(data, connect, disconnect, NULL, destroy, + user_data); + if (cb == NULL) + return 0; + + if (connect) + check_service(connection, name, cb); + + return cb->id; +} + +guint g_dbus_add_disconnect_watch(DBusConnection *connection, const char *name, + GDBusWatchFunction func, + void *user_data, GDBusDestroyFunction destroy) +{ + return g_dbus_add_service_watch(connection, name, NULL, func, + user_data, destroy); +} + +guint g_dbus_add_signal_watch(DBusConnection *connection, + const char *sender, const char *path, + const char *interface, const char *member, + GDBusSignalFunction function, void *user_data, + GDBusDestroyFunction destroy) +{ + struct filter_data *data; + struct filter_callback *cb; + + data = filter_data_get(connection, signal_filter, sender, path, + interface, member, NULL); + if (data == NULL) + return 0; + + cb = filter_data_add_callback(data, NULL, NULL, function, destroy, + user_data); + if (cb == NULL) + return 0; + + if (data->name != NULL && data->name_watch == 0) + data->name_watch = g_dbus_add_service_watch(connection, + data->name, NULL, + NULL, NULL, NULL); + + return cb->id; +} + +guint g_dbus_add_properties_watch(DBusConnection *connection, + const char *sender, const char *path, + const char *interface, + GDBusSignalFunction function, void *user_data, + GDBusDestroyFunction destroy) +{ + struct filter_data *data; + struct filter_callback *cb; + + data = filter_data_get(connection, signal_filter, sender, path, + DBUS_INTERFACE_PROPERTIES, "PropertiesChanged", + interface); + if (data == NULL) + return 0; + + cb = filter_data_add_callback(data, NULL, NULL, function, destroy, + user_data); + if (cb == NULL) + return 0; + + if (data->name != NULL && data->name_watch == 0) + data->name_watch = g_dbus_add_service_watch(connection, + data->name, NULL, + NULL, NULL, NULL); + + return cb->id; +} + +gboolean g_dbus_remove_watch(DBusConnection *connection, guint id) +{ + struct filter_data *data; + struct filter_callback *cb; + GSList *ldata; + + if (id == 0) + return FALSE; + + for (ldata = listeners; ldata; ldata = ldata->next) { + data = ldata->data; + + cb = filter_data_find_callback(data, id); + if (cb) { + filter_data_remove_callback(data, cb); + return TRUE; + } + } + + return FALSE; +} + +void g_dbus_remove_all_watches(DBusConnection *connection) +{ + struct filter_data *data; + + while ((data = filter_data_find(connection))) { + listeners = g_slist_remove(listeners, data); + filter_data_call_and_free(data); + } +}
diff --git a/neard/include/adapter.h b/neard/include/adapter.h new file mode 100644 index 0000000..19ff603 --- /dev/null +++ b/neard/include/adapter.h
@@ -0,0 +1,37 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NEAR_ADAPTER_H +#define __NEAR_ADAPTER_H + +#include <stdint.h> +#include <stdlib.h> +#include <unistd.h> + +typedef int (*near_recv)(uint8_t *resp, int length, void *data); +typedef int (*near_release)(int err, void *data); + +int near_adapter_connect(uint32_t idx, uint32_t target_idx, uint8_t protocol); +int near_adapter_disconnect(uint32_t idx); +int near_adapter_send(uint32_t idx, uint8_t *buf, size_t length, + near_recv rx_cb, void *data, near_release data_rel); + +#endif
diff --git a/neard/include/dbus.h b/neard/include/dbus.h new file mode 100644 index 0000000..a813915 --- /dev/null +++ b/neard/include/dbus.h
@@ -0,0 +1,148 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <dbus/dbus.h> + +#define NFC_SERVICE "org.neard" +#define NFC_PATH "/org/neard" + +#define NFC_ERROR_INTERFACE NFC_SERVICE ".Error" +#define NFC_AGENT_MANAGER_INTERFACE NFC_SERVICE ".AgentManager" +#define NFC_NDEF_AGENT_INTERFACE NFC_SERVICE ".NDEFAgent" +#define NFC_HANDOVER_AGENT_INTERFACE NFC_SERVICE ".HandoverAgent" + +#define NFC_ADAPTER_INTERFACE NFC_SERVICE ".Adapter" +#define NFC_DEVICE_INTERFACE NFC_SERVICE ".Device" +#define NFC_TAG_INTERFACE NFC_SERVICE ".Tag" +#define NFC_RECORD_INTERFACE NFC_SERVICE ".Record" + +#define SEEL_SERVICE "org.neard.se" +#define SEEL_PATH "/org/neard/se" + +#define SEEL_ERROR_INTERFACE SEEL_SERVICE ".Error" + +#define SEEL_MANAGER_INTERFACE SEEL_SERVICE ".Manager" +#define SEEL_MANAGER_PATH "/" + +#define SEEL_SE_INTERFACE SEEL_SERVICE ".SecureElement" +#define SEEL_CHANNEL_INTERFACE SEEL_SERVICE ".Channel" + +typedef void (* near_dbus_append_cb_t) (DBusMessageIter *iter, + void *user_data); + +DBusConnection *near_dbus_get_connection(void); + +void near_dbus_property_append_basic(DBusMessageIter *iter, + const char *key, int type, void *val); +void near_dbus_property_append_dict(DBusMessageIter *iter, const char *key, + near_dbus_append_cb_t function, void *user_data); +void near_dbus_property_append_array(DBusMessageIter *iter, + const char *key, int type, + near_dbus_append_cb_t function, void *user_data); +void near_dbus_property_append_fixed_array(DBusMessageIter *iter, + const char *key, int type, void *val, int len); + +dbus_bool_t near_dbus_property_changed_basic(const char *path, + const char *interface, const char *key, + int type, void *val); +dbus_bool_t near_dbus_property_changed_dict(const char *path, + const char *interface, const char *key, + near_dbus_append_cb_t function, void *user_data); +dbus_bool_t near_dbus_property_changed_array(const char *path, + const char *interface, const char *key, int type, + near_dbus_append_cb_t function, void *user_data); + +dbus_bool_t near_dbus_setting_changed_basic(const char *owner, + const char *path, const char *key, + int type, void *val); +dbus_bool_t near_dbus_setting_changed_dict(const char *owner, + const char *path, const char *key, + near_dbus_append_cb_t function, + void *user_data); +dbus_bool_t near_dbus_setting_changed_array(const char *owner, + const char *path, const char *key, int type, + near_dbus_append_cb_t function, + void *user_data); + +static inline void near_dbus_dict_open(DBusMessageIter *iter, + DBusMessageIter *dict) +{ + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, dict); +} + +static inline void near_dbus_dict_close(DBusMessageIter *iter, + DBusMessageIter *dict) +{ + dbus_message_iter_close_container(iter, dict); +} + +static inline void near_dbus_dict_append_basic(DBusMessageIter *dict, + const char *key, int type, void *val) +{ + DBusMessageIter entry; + + dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, + NULL, &entry); + near_dbus_property_append_basic(&entry, key, type, val); + dbus_message_iter_close_container(dict, &entry); +} + +static inline void near_dbus_dict_append_dict(DBusMessageIter *dict, + const char *key, near_dbus_append_cb_t function, + void *user_data) +{ + DBusMessageIter entry; + + dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, + NULL, &entry); + near_dbus_property_append_dict(&entry, key, function, user_data); + dbus_message_iter_close_container(dict, &entry); +} + +static inline void near_dbus_dict_append_array(DBusMessageIter *dict, + const char *key, int type, near_dbus_append_cb_t function, + void *user_data) +{ + DBusMessageIter entry; + + dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, + NULL, &entry); + near_dbus_property_append_array(&entry, key, + type, function, user_data); + dbus_message_iter_close_container(dict, &entry); +} + +static inline void near_dbus_dict_append_fixed_array(DBusMessageIter *dict, + const char *key, int type, void *val, int len) +{ + DBusMessageIter entry; + + dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, + NULL, &entry); + near_dbus_property_append_fixed_array(&entry, key, type, val, len); + dbus_message_iter_close_container(dict, &entry); +} + +dbus_bool_t near_dbus_validate_ident(const char *ident); +char *near_dbus_encode_string(const char *value);
diff --git a/neard/include/device.h b/neard/include/device.h new file mode 100644 index 0000000..15df8a9 --- /dev/null +++ b/neard/include/device.h
@@ -0,0 +1,63 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NEAR_DEVICE_H +#define __NEAR_DEVICE_H + +#include <stdint.h> + +#include <glib.h> + +struct near_device; + +typedef void (*near_device_io_cb) (uint32_t adapter_idx, uint32_t target_idx, + int status); + +struct near_ndef_message; + +#define NEAR_DEVICE_PRIORITY_LOW -100 +#define NEAR_DEVICE_PRIORITY_DEFAULT 0 +#define NEAR_DEVICE_PRIORITY_HIGH 100 + +#define NEAR_DEVICE_SN_NPP "com.android.npp" +#define NEAR_DEVICE_SN_SNEP "urn:nfc:sn:snep" +#define NEAR_DEVICE_SN_HANDOVER "urn:nfc:sn:handover" + +struct near_device_driver { + int priority; + + int (*listen)(uint32_t adapter_idx, near_device_io_cb cb); + int (*push)(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + char *service_name, + near_device_io_cb cb); +}; + +struct near_device *near_device_get_device(uint32_t adapter_idx, + uint32_t target_idx); +int near_device_add_data(uint32_t adapter_idx, uint32_t target_idx, + uint8_t *data, size_t data_length); +int near_device_add_records(struct near_device *device, GList *records, + near_device_io_cb cb, int status); +int near_device_driver_register(struct near_device_driver *driver); +void near_device_driver_unregister(struct near_device_driver *driver); + +#endif
diff --git a/neard/include/log.h b/neard/include/log.h new file mode 100644 index 0000000..6183b88 --- /dev/null +++ b/neard/include/log.h
@@ -0,0 +1,47 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +void near_info(const char *format, ...) + __attribute__((format(printf, 1, 2))); +void near_warn(const char *format, ...) + __attribute__((format(printf, 1, 2))); +void near_error(const char *format, ...) + __attribute__((format(printf, 1, 2))); +void near_debug(const char *format, ...) + __attribute__((format(printf, 1, 2))); + +struct near_debug_desc { + const char *name; + const char *file; +#define NEAR_DEBUG_FLAG_DEFAULT (0) +#define NEAR_DEBUG_FLAG_PRINT (1 << 0) + unsigned int flags; +} __attribute__((aligned(8))); + +#define DBG(fmt, arg...) do { \ + static struct near_debug_desc __near_debug_desc \ + __attribute__((used, section("__debug"), aligned(8))) = { \ + .file = __FILE__, .flags = NEAR_DEBUG_FLAG_DEFAULT, \ + }; \ + if (__near_debug_desc.flags & NEAR_DEBUG_FLAG_PRINT) \ + near_debug("%s:%s() " fmt, \ + __FILE__, __FUNCTION__ , ## arg); \ +} while (0)
diff --git a/neard/include/ndef.h b/neard/include/ndef.h new file mode 100644 index 0000000..5abdf34 --- /dev/null +++ b/neard/include/ndef.h
@@ -0,0 +1,76 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NEAR_NDEF_H +#define __NEAR_NDEF_H + +#include <stdbool.h> + +#include <near/tag.h> + +struct near_ndef_record; +struct carrier_data; + +struct near_ndef_message { + size_t length; + size_t offset; + uint8_t *data; +}; + +int near_ndef_count_records(uint8_t *ndef_in, size_t ndef_in_length, + uint8_t record_type); + +int near_ndef_record_length(uint8_t *ndef_in, size_t ndef_in_length); + +GList *near_ndef_parse_msg(uint8_t *ndef_data, size_t ndef_length, + struct near_ndef_message **reply); + +void near_ndef_records_free(GList *records); + +struct near_ndef_message *near_ndef_prepare_text_record(char *encoding, + char *language_code, char *text); + +struct near_ndef_message *near_ndef_prepare_uri_record(uint8_t identifier, + uint32_t field_length, uint8_t *field); + +struct near_ndef_message *near_ndef_prepare_handover_record(char* type_name, + struct near_ndef_record *record, + uint8_t carriers, + struct carrier_data *remote); + +struct near_ndef_message * +near_ndef_prepare_smartposter_record(uint8_t uri_identifier, + uint32_t uri_field_length, + uint8_t *uri_field); + +bool near_ndef_record_cmp_id(struct near_ndef_record *rec1, + struct near_ndef_record *rec2); +bool near_ndef_record_cmp_mime(struct near_ndef_record *rec1, + struct near_ndef_record *rec2); + + +size_t near_ndef_data_length(struct near_ndef_record *data); +uint8_t *near_ndef_data_ptr(struct near_ndef_record *data); + +struct near_ndef_message *near_ndef_prepare_wsc_record(char *ssid, + char *passphrase); + +#endif
diff --git a/neard/include/nfc_copy.h b/neard/include/nfc_copy.h new file mode 100644 index 0000000..f78c8d8 --- /dev/null +++ b/neard/include/nfc_copy.h
@@ -0,0 +1,326 @@ +/* + * Copyright (C) 2011 Instituto Nokia de Tecnologia + * + * Authors: + * Lauro Ramos Venancio <lauro.venancio@openbossa.org> + * Aloisio Almeida Jr <aloisio.almeida@openbossa.org> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef __LINUX_NFC_H +#define __LINUX_NFC_H + +#include <linux/types.h> +#include <linux/socket.h> + +#define NFC_GENL_NAME "nfc" +#define NFC_GENL_VERSION 1 + +#define NFC_GENL_MCAST_EVENT_NAME "events" + +/** + * enum nfc_commands - supported nfc commands + * + * @NFC_CMD_UNSPEC: unspecified command + * + * @NFC_CMD_GET_DEVICE: request information about a device (requires + * %NFC_ATTR_DEVICE_INDEX) or dump request to get a list of all nfc devices + * @NFC_CMD_DEV_UP: turn on the nfc device + * (requires %NFC_ATTR_DEVICE_INDEX) + * @NFC_CMD_DEV_DOWN: turn off the nfc device + * (requires %NFC_ATTR_DEVICE_INDEX) + * @NFC_CMD_START_POLL: start polling for targets using the given protocols + * (requires %NFC_ATTR_DEVICE_INDEX and %NFC_ATTR_PROTOCOLS) + * @NFC_CMD_STOP_POLL: stop polling for targets (requires + * %NFC_ATTR_DEVICE_INDEX) + * @NFC_CMD_GET_TARGET: dump all targets found by the previous poll (requires + * %NFC_ATTR_DEVICE_INDEX) + * @NFC_EVENT_TARGETS_FOUND: event emitted when a new target is found + * (it sends %NFC_ATTR_DEVICE_INDEX) + * @NFC_EVENT_DEVICE_ADDED: event emitted when a new device is registred + * (it sends %NFC_ATTR_DEVICE_NAME, %NFC_ATTR_DEVICE_INDEX and + * %NFC_ATTR_PROTOCOLS) + * @NFC_EVENT_DEVICE_REMOVED: event emitted when a device is removed + * (it sends %NFC_ATTR_DEVICE_INDEX) + * @NFC_EVENT_TM_ACTIVATED: event emitted when the adapter is activated in + * target mode. + * @NFC_EVENT_DEVICE_DEACTIVATED: event emitted when the adapter is deactivated + * from target mode. + * @NFC_CMD_LLC_GET_PARAMS: request LTO, RW, and MIUX parameters for a device + * @NFC_CMD_LLC_SET_PARAMS: set one or more of LTO, RW, and MIUX parameters for + * a device. LTO must be set before the link is up otherwise -EINPROGRESS + * is returned. RW and MIUX can be set at anytime and will be passed in + * subsequent CONNECT and CC messages. + * If one of the passed parameters is wrong none is set and -EINVAL is + * returned. + * @NFC_CMD_ENABLE_SE: Enable the physical link to a specific secure element. + * Once enabled a secure element will handle card emulation mode, i.e. + * starting a poll from a device which has a secure element enabled means + * we want to do SE based card emulation. + * @NFC_CMD_DISABLE_SE: Disable the physical link to a specific secure element. + * @NFC_CMD_FW_DOWNLOAD: Request to Load/flash firmware, or event to inform + * that some firmware was loaded + * @NFC_EVENT_SE_ADDED: Event emitted when a new secure element is discovered. + * This typically will be sent whenever a new NFC controller with either + * an embedded SE or an UICC one connected to it through SWP. + * @NFC_EVENT_SE_REMOVED: Event emitted when a secure element is removed from + * the system, as a consequence of e.g. an NFC controller being unplugged. + * @NFC_EVENT_SE_CONNECTIVITY: This event is emitted whenever a secure element + * is requesting connectivity access. For example a UICC SE may need to + * talk with a sleeping modem and will notify this need by sending this + * event. It is then up to userspace to decide if it will wake the modem + * up or not. + * @NFC_EVENT_SE_TRANSACTION: This event is sent when an application running on + * a specific SE notifies us about the end of a transaction. The parameter + * for this event is the application ID (AID). + * @NFC_CMD_GET_SE: Dump all discovered secure elements from an NFC controller. + * @NFC_CMD_SE_IO: Send/Receive APDUs to/from the selected secure element. + * @NFC_CMD_VENDOR: Vendor specific command, to be implemented directly + * from the driver in order to support hardware specific operations. + * @NFC_EVENT_VENDOR_RSP: Vendor specific response, to be implemented directly + * from the driver in order to support hardware specific operations. + */ +enum nfc_commands { + NFC_CMD_UNSPEC, + NFC_CMD_GET_DEVICE, + NFC_CMD_DEV_UP, + NFC_CMD_DEV_DOWN, + NFC_CMD_DEP_LINK_UP, + NFC_CMD_DEP_LINK_DOWN, + NFC_CMD_START_POLL, + NFC_CMD_STOP_POLL, + NFC_CMD_GET_TARGET, + NFC_EVENT_TARGETS_FOUND, + NFC_EVENT_DEVICE_ADDED, + NFC_EVENT_DEVICE_REMOVED, + NFC_EVENT_TARGET_LOST, + NFC_EVENT_TM_ACTIVATED, + NFC_EVENT_TM_DEACTIVATED, + NFC_CMD_LLC_GET_PARAMS, + NFC_CMD_LLC_SET_PARAMS, + NFC_CMD_ENABLE_SE, + NFC_CMD_DISABLE_SE, + NFC_CMD_LLC_SDREQ, + NFC_EVENT_LLC_SDRES, + NFC_CMD_FW_DOWNLOAD, + NFC_EVENT_SE_ADDED, + NFC_EVENT_SE_REMOVED, + NFC_EVENT_SE_CONNECTIVITY, + NFC_EVENT_SE_TRANSACTION, + NFC_CMD_GET_SE, + NFC_CMD_SE_IO, + NFC_CMD_ACTIVATE_TARGET, + NFC_CMD_VENDOR, + NFC_EVENT_VENDOR_RSP, +/* private: internal use only */ + __NFC_CMD_AFTER_LAST +}; +#define NFC_CMD_MAX (__NFC_CMD_AFTER_LAST - 1) + +/** + * enum nfc_attrs - supported nfc attributes + * + * @NFC_ATTR_UNSPEC: unspecified attribute + * + * @NFC_ATTR_DEVICE_INDEX: index of nfc device + * @NFC_ATTR_DEVICE_NAME: device name, max 8 chars + * @NFC_ATTR_PROTOCOLS: nfc protocols - bitwise or-ed combination from + * NFC_PROTO_*_MASK constants + * @NFC_ATTR_TARGET_INDEX: index of the nfc target + * @NFC_ATTR_TARGET_SENS_RES: NFC-A targets extra information such as NFCID + * @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the + * target is not NFC-Forum compliant) + * @NFC_ATTR_TARGET_NFCID1: NFC-A targets identifier, max 10 bytes + * @NFC_ATTR_TARGET_SENSB_RES: NFC-B targets extra information, max 12 bytes + * @NFC_ATTR_TARGET_SENSF_RES: NFC-F targets extra information, max 18 bytes + * @NFC_ATTR_COMM_MODE: Passive or active mode + * @NFC_ATTR_RF_MODE: Initiator or target + * @NFC_ATTR_IM_PROTOCOLS: Initiator mode protocols to poll for + * @NFC_ATTR_TM_PROTOCOLS: Target mode protocols to listen for + * @NFC_ATTR_LLC_PARAM_LTO: Link TimeOut parameter + * @NFC_ATTR_LLC_PARAM_RW: Receive Window size parameter + * @NFC_ATTR_LLC_PARAM_MIUX: MIU eXtension parameter + * @NFC_ATTR_SE: Available Secure Elements + * @NFC_ATTR_FIRMWARE_NAME: Free format firmware version + * @NFC_ATTR_SE_INDEX: Secure element index + * @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED) + * @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status + * @NFC_ATTR_APDU: Secure element APDU + * @NFC_ATTR_TARGET_ISO15693_DSFID: ISO 15693 Data Storage Format Identifier + * @NFC_ATTR_TARGET_ISO15693_UID: ISO 15693 Unique Identifier + * @NFC_ATTR_VENDOR_ID: NFC manufacturer unique ID, typically an OUI + * @NFC_ATTR_VENDOR_SUBCMD: Vendor specific sub command + * @NFC_ATTR_VENDOR_DATA: Vendor specific data, to be optionally passed + * to a vendor specific command implementation + */ +enum nfc_attrs { + NFC_ATTR_UNSPEC, + NFC_ATTR_DEVICE_INDEX, + NFC_ATTR_DEVICE_NAME, + NFC_ATTR_PROTOCOLS, + NFC_ATTR_TARGET_INDEX, + NFC_ATTR_TARGET_SENS_RES, + NFC_ATTR_TARGET_SEL_RES, + NFC_ATTR_TARGET_NFCID1, + NFC_ATTR_TARGET_SENSB_RES, + NFC_ATTR_TARGET_SENSF_RES, + NFC_ATTR_COMM_MODE, + NFC_ATTR_RF_MODE, + NFC_ATTR_DEVICE_POWERED, + NFC_ATTR_IM_PROTOCOLS, + NFC_ATTR_TM_PROTOCOLS, + NFC_ATTR_LLC_PARAM_LTO, + NFC_ATTR_LLC_PARAM_RW, + NFC_ATTR_LLC_PARAM_MIUX, + NFC_ATTR_SE, + NFC_ATTR_LLC_SDP, + NFC_ATTR_FIRMWARE_NAME, + NFC_ATTR_SE_INDEX, + NFC_ATTR_SE_TYPE, + NFC_ATTR_SE_AID, + NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS, + NFC_ATTR_SE_APDU, + NFC_ATTR_TARGET_ISO15693_DSFID, + NFC_ATTR_TARGET_ISO15693_UID, + NFC_ATTR_SE_PARAMS, + NFC_ATTR_VENDOR_ID, + NFC_ATTR_VENDOR_SUBCMD, + NFC_ATTR_VENDOR_DATA, +/* private: internal use only */ + __NFC_ATTR_AFTER_LAST +}; +#define NFC_ATTR_MAX (__NFC_ATTR_AFTER_LAST - 1) + +enum nfc_sdp_attr { + NFC_SDP_ATTR_UNSPEC, + NFC_SDP_ATTR_URI, + NFC_SDP_ATTR_SAP, +/* private: internal use only */ + __NFC_SDP_ATTR_AFTER_LAST +}; +#define NFC_SDP_ATTR_MAX (__NFC_SDP_ATTR_AFTER_LAST - 1) + +#define NFC_DEVICE_NAME_MAXSIZE 8 +#define NFC_NFCID1_MAXSIZE 10 +#define NFC_NFCID2_MAXSIZE 8 +#define NFC_NFCID3_MAXSIZE 10 +#define NFC_SENSB_RES_MAXSIZE 12 +#define NFC_SENSF_RES_MAXSIZE 18 +#define NFC_ATR_REQ_MAXSIZE 64 +#define NFC_ATR_RES_MAXSIZE 64 +#define NFC_ATR_REQ_GB_MAXSIZE 48 +#define NFC_ATR_RES_GB_MAXSIZE 47 +#define NFC_GB_MAXSIZE 48 +#define NFC_FIRMWARE_NAME_MAXSIZE 32 +#define NFC_ISO15693_UID_MAXSIZE 8 + +/* NFC protocols */ +#define NFC_PROTO_JEWEL 1 +#define NFC_PROTO_MIFARE 2 +#define NFC_PROTO_FELICA 3 +#define NFC_PROTO_ISO14443 4 +#define NFC_PROTO_NFC_DEP 5 +#define NFC_PROTO_ISO14443_B 6 +#define NFC_PROTO_ISO15693 7 + +#define NFC_PROTO_MAX 8 + +/* NFC communication modes */ +#define NFC_COMM_ACTIVE 0 +#define NFC_COMM_PASSIVE 1 + +/* NFC RF modes */ +#define NFC_RF_INITIATOR 0 +#define NFC_RF_TARGET 1 +#define NFC_RF_NONE 2 + +/* NFC protocols masks used in bitsets */ +#define NFC_PROTO_JEWEL_MASK (1 << NFC_PROTO_JEWEL) +#define NFC_PROTO_MIFARE_MASK (1 << NFC_PROTO_MIFARE) +#define NFC_PROTO_FELICA_MASK (1 << NFC_PROTO_FELICA) +#define NFC_PROTO_ISO14443_MASK (1 << NFC_PROTO_ISO14443) +#define NFC_PROTO_NFC_DEP_MASK (1 << NFC_PROTO_NFC_DEP) +#define NFC_PROTO_ISO14443_B_MASK (1 << NFC_PROTO_ISO14443_B) +#define NFC_PROTO_ISO15693_MASK (1 << NFC_PROTO_ISO15693) + +/* NFC Secure Elements */ +#define NFC_SE_UICC 0x1 +#define NFC_SE_EMBEDDED 0x2 + +#define NFC_SE_DISABLED 0x0 +#define NFC_SE_ENABLED 0x1 + +struct sockaddr_nfc { + sa_family_t sa_family; + __u32 dev_idx; + __u32 target_idx; + __u32 nfc_protocol; +}; + +#define NFC_LLCP_MAX_SERVICE_NAME 63 +struct sockaddr_nfc_llcp { + sa_family_t sa_family; + __u32 dev_idx; + __u32 target_idx; + __u32 nfc_protocol; + __u8 dsap; /* Destination SAP, if known */ + __u8 ssap; /* Source SAP to be bound to */ + char service_name[NFC_LLCP_MAX_SERVICE_NAME]; /* Service name URI */; + size_t service_name_len; +}; + +/* NFC socket protocols */ +#define NFC_SOCKPROTO_RAW 0 +#define NFC_SOCKPROTO_LLCP 1 +#define NFC_SOCKPROTO_MAX 2 + +#define NFC_HEADER_SIZE 1 + +/** + * Pseudo-header info for raw socket packets + * First byte is the adapter index + * Second byte contains flags + * - 0x01 - Direction (0=RX, 1=TX) + * - 0x02-0x04 - Payload type (000=LLCP, 001=NCI, 010=HCI, 011=Digital, + * 100=Proprietary) + * - 0x05-0x80 - Reserved + **/ +#define NFC_RAW_HEADER_SIZE 2 +#define NFC_DIRECTION_RX 0x00 +#define NFC_DIRECTION_TX 0x01 + +#define NFC_LLCP_RAW_HEADER_SIZE 2 +#define NFC_LLCP_DIRECTION_RX 0x00 +#define NFC_LLCP_DIRECTION_TX 0x01 + +#define RAW_PAYLOAD_LLCP 0 +#define RAW_PAYLOAD_NCI 1 +#define RAW_PAYLOAD_HCI 2 +#define RAW_PAYLOAD_DIGITAL 3 +#define RAW_PAYLOAD_PROPRIETARY 4 + +#define RAW_PAYLOAD_LLCP 0 +#define RAW_PAYLOAD_NCI 1 +#define RAW_PAYLOAD_HCI 2 +#define RAW_PAYLOAD_DIGITAL 3 +#define RAW_PAYLOAD_PROPRIETARY 4 + +/* socket option names */ +#define NFC_LLCP_RW 0 +#define NFC_LLCP_MIUX 1 +#define NFC_LLCP_REMOTE_MIU 2 +#define NFC_LLCP_REMOTE_LTO 3 +#define NFC_LLCP_REMOTE_RW 4 + +#endif /*__LINUX_NFC_H */
diff --git a/neard/include/plugin.h b/neard/include/plugin.h new file mode 100644 index 0000000..609775d --- /dev/null +++ b/neard/include/plugin.h
@@ -0,0 +1,95 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +#ifndef __NEAR_PLUGIN_H +#define __NEAR_PLUGIN_H + +#include <near/version.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define NEAR_PLUGIN_PRIORITY_LOW -100 +#define NEAR_PLUGIN_PRIORITY_DEFAULT 0 +#define NEAR_PLUGIN_PRIORITY_HIGH 100 + +/** + * SECTION:plugin + * @title: Plugin premitives + * @short_description: Functions for declaring plugins + */ + +struct near_plugin_desc { + const char *name; + const char *description; + const char *version; + int priority; + int (*init) (void); + void (*exit) (void); +}; + +/** + * NEAR_PLUGIN_DEFINE: + * @name: plugin name + * @description: plugin description + * @version: plugin version string + * @init: init function called on plugin loading + * @exit: exit function called on plugin removal + * + * Macro for defining a plugin descriptor + * + * |[ + * #include <near/plugin.h> + * + * static int example_init(void) + * { + * return 0; + * } + * + * static void example_exit(void) + * { + * } + * + * NEAR_PLUGIN_DEFINE(example, "Example plugin", NEAR_VERSION, + * example_init, example_exit) + * ]| + */ +#ifdef NEAR_PLUGIN_BUILTIN +#define NEAR_PLUGIN_DEFINE(name, description, version, priority, init, exit) \ + struct near_plugin_desc __near_builtin_ ## name = { \ + #name, description, version, priority, init, exit \ + }; +#else +#define NEAR_PLUGIN_DEFINE(name, description, version, priority, init, exit) \ + extern struct near_plugin_desc near_plugin_desc \ + __attribute__ ((visibility("default"))); \ + struct near_plugin_desc near_plugin_desc = { \ + #name, description, version, priority, init, exit \ + }; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __NEAR_PLUGIN_H */
diff --git a/neard/include/setting.h b/neard/include/setting.h new file mode 100644 index 0000000..31a0426 --- /dev/null +++ b/neard/include/setting.h
@@ -0,0 +1,37 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NEAR_SETTING_H +#define __NEAR_SETTING_H + +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif + +bool near_setting_get_bool(const char *key); + +#ifdef __cplusplus +} +#endif + +#endif /* __NEAR_SETTING_H */
diff --git a/neard/include/snep.h b/neard/include/snep.h new file mode 100644 index 0000000..5392c58 --- /dev/null +++ b/neard/include/snep.h
@@ -0,0 +1,102 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NEAR_SNEP_CORE_H +#define __NEAR_SNEP_CORE_H + +#include <stdbool.h> + +#include <near/device.h> + +#define NEAR_SNEP_VERSION 0x10 +#define NEAR_SNEP_MAJOR(version) (((version) >> 4) & 0xf) +#define NEAR_SNEP_MINOR(version) ((version) & 0xf) + +#define NEAR_SNEP_MSG_SIZE 0x06 +#define NEAR_SNEP_ACCEPTABLE_LENGTH 1024 +#define NEAR_SNEP_ACC_LENGTH_SIZE 4 + +/* Request codes */ +#define NEAR_SNEP_REQ_CONTINUE 0x00 +#define NEAR_SNEP_REQ_GET 0x01 +#define NEAR_SNEP_REQ_PUT 0x02 +#define NEAR_SNEP_REQ_REJECT 0x7f + +/* Response codes */ +#define NEAR_SNEP_RESP_CONTINUE 0x80 +#define NEAR_SNEP_RESP_SUCCESS 0x81 +#define NEAR_SNEP_RESP_NOT_FOUND 0xc0 +#define NEAR_SNEP_RESP_EXCESS 0xc1 +#define NEAR_SNEP_RESP_BAD_REQ 0xc2 +#define NEAR_SNEP_RESP_NOT_IMPL 0xe0 +#define NEAR_SNEP_RESP_VERSION 0xe1 +#define NEAR_SNEP_RESP_REJECT 0xff + +#define NEAR_SNEP_REQ_PUT_HEADER_LENGTH 6 +#define NEAR_SNEP_REQ_GET_HEADER_LENGTH 10 + +/* Default SNEP Resp message header length: Version + code + len */ +#define NEAR_SNEP_RESP_HEADER_LENGTH (1 + 1 + 4) + +/* Offset of 'H' in Android frame: 3 is the offset in NDEF */ +#define NEAR_SNEP_REQ_ANDROID (NEAR_SNEP_ACC_LENGTH_SIZE + 3) + + +/* TODO: Right now it is dummy, need to get correct value + * from lower layers */ +#define NEAR_SNEP_REQ_MAX_FRAGMENT_LENGTH 128 + +typedef bool (*near_server_io) (int client_fd, void *snep_data); + +struct p2p_snep_data { + uint8_t *nfc_data; + uint32_t nfc_data_length; + uint32_t nfc_data_current_length; + uint8_t *nfc_data_ptr; + uint32_t adapter_idx; + uint32_t target_idx; + bool respond_continue; + uint8_t request; + near_tag_io_cb cb; + struct p2p_snep_put_req_data *req; +}; + +bool near_snep_core_read(int client_fd, + uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, + near_server_io req_get, + near_server_io req_put, + gpointer data); + +int near_snep_core_push(int fd, uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_device_io_cb cb, + gpointer data); + +void near_snep_core_close(int client_fd, int err, gpointer data); + +void near_snep_core_response_noinfo(int client_fd, uint8_t response); +void near_snep_core_response_with_info(int client_fd, uint8_t response, + uint8_t *data, int length); +void near_snep_core_parse_handover_record(int client_fd, uint8_t *ndef, + uint32_t nfc_data_length); + +#endif
diff --git a/neard/include/tag.h b/neard/include/tag.h new file mode 100644 index 0000000..5332027 --- /dev/null +++ b/neard/include/tag.h
@@ -0,0 +1,126 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NEAR_TAG_H +#define __NEAR_TAG_H + +#include <stdint.h> +#include <stdbool.h> + +#include <glib.h> + +#define NFC_HEADER_SIZE 1 + +#define NFC_MAX_NFCID1_LEN 10 +#define NFC_MAX_ISO15693_DSFID_LEN 1 +#define NFC_MAX_ISO15693_UID_LEN 8 + +enum near_tag_sub_type { + NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT = 0, // SAK 0x00 + NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K, // SAK:0x08 + NEAR_TAG_NFC_T2_MIFARE_MINI, // SAK 0x09 + NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K, // SAK:0x18 + NEAR_TAG_NFC_T2_MIFARE_DESFIRE, // SAK:0x20 + NEAR_TAG_NFC_T2_JCOP30, // SAK:0x28 + NEAR_TAG_NFC_T2_MIFARE_4K_EMUL, // SAK:0x38 + NEAR_TAG_NFC_T2_MIFARE_1K_INFINEON, // SAK:0x88 + NEAR_TAG_NFC_T2_MPCOS, // SAK:0x98 + NEAR_TAG_NFC_SUBTYPE_UNKNOWN = 0xFF +}; + +enum near_tag_memory_layout { + NEAR_TAG_MEMORY_STATIC = 0, + NEAR_TAG_MEMORY_DYNAMIC, + NEAR_TAG_MEMORY_OTHER, + NEAR_TAG_MEMORY_UNKNOWN = 0xFF +}; + +typedef void (*near_tag_io_cb) (uint32_t adapter_idx, uint32_t target_idx, + int status); + +struct near_ndef_message; + +#define NEAR_TAG_PRIORITY_LOW -100 +#define NEAR_TAG_PRIORITY_DEFAULT 0 +#define NEAR_TAG_PRIORITY_HIGH 100 + +struct near_tag_driver { + uint16_t type; + int priority; + + int (*read)(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb); + int (*write)(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_tag_io_cb cb); + int (*check_presence)(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb); + int (*format)(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb); +}; + +struct near_tag; + +struct near_tag *near_tag_get_tag(uint32_t adapter_idx, uint32_t target_idx); +void near_tag_set_ro(struct near_tag *tag, bool readonly); +void near_tag_set_blank(struct near_tag *tag, bool blank); +bool near_tag_get_blank(struct near_tag *tag); +int near_tag_add_data(uint32_t adapter_idx, uint32_t target_idx, + uint8_t *data, size_t data_length); +int near_tag_add_records(struct near_tag *tag, GList *records, + near_tag_io_cb cb, int status); +enum near_tag_sub_type near_tag_get_subtype(uint32_t adapter_idx, + uint32_t target_idx); +uint8_t *near_tag_get_nfcid(uint32_t adapter_idx, uint32_t target_idx, + uint8_t *nfcid_len); +int near_tag_set_nfcid(uint32_t adapter_idx, uint32_t target_idx, + uint8_t *nfcid, size_t nfcid_len); +uint8_t *near_tag_get_iso15693_dsfid(uint32_t adapter_idx, uint32_t target_idx); +uint8_t *near_tag_get_iso15693_uid(uint32_t adapter_idx, uint32_t target_idx); +uint8_t *near_tag_get_data(struct near_tag *tag, size_t *data_length); +size_t near_tag_get_data_length(struct near_tag *tag); +uint32_t near_tag_get_adapter_idx(struct near_tag *tag); +uint32_t near_tag_get_target_idx(struct near_tag *tag); +int near_tag_driver_register(struct near_tag_driver *driver); +void near_tag_driver_unregister(struct near_tag_driver *driver); +void near_tag_set_memory_layout(struct near_tag *tag, + enum near_tag_memory_layout); +enum near_tag_memory_layout near_tag_get_memory_layout(struct near_tag *tag); +void near_tag_set_max_ndef_size(struct near_tag *tag, uint16_t size); +uint16_t near_tag_get_max_ndef_size(struct near_tag *tag); +void near_tag_set_c_apdu_max_size(struct near_tag *tag, uint16_t size); +uint16_t near_tag_get_c_apdu_max_size(struct near_tag *tag); +void near_tag_set_r_apdu_max_size(struct near_tag *tag, uint16_t size); +uint16_t near_tag_get_r_apdu_max_size(struct near_tag *tag); +void near_tag_set_file_id(struct near_tag *tag, uint16_t file_id); +uint16_t near_tag_get_file_id(struct near_tag *tag); +void near_tag_set_idm(struct near_tag *tag, uint8_t *idm, uint8_t len); +uint8_t *near_tag_get_idm(struct near_tag *tag, uint8_t *len); +void near_tag_set_attr_block(struct near_tag *tag, uint8_t *attr, uint8_t len); +uint8_t *near_tag_get_attr_block(struct near_tag *tag, uint8_t *len); +void near_tag_set_ic_type(struct near_tag *tag, uint8_t ic_type); +uint8_t near_tag_get_ic_type(struct near_tag *tag); +uint8_t near_tag_get_blk_size(struct near_tag *tag); +void near_tag_set_blk_size(struct near_tag *tag, uint8_t blk_size); +uint8_t near_tag_get_num_blks(struct near_tag *tag); +void near_tag_set_num_blks(struct near_tag *tag, uint8_t num_blks); + +#endif
diff --git a/neard/include/tlv.h b/neard/include/tlv.h new file mode 100644 index 0000000..b4db3ea --- /dev/null +++ b/neard/include/tlv.h
@@ -0,0 +1,39 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NEAR_TLV_H +#define __NEAR_TLV_H + +#define TLV_NULL 0x00 +#define TLV_LOCK 0x01 +#define TLV_MEM 0x02 +#define TLV_NDEF 0x03 +#define TLV_PROP 0xfd +#define TLV_END 0xfe + +#define TLV_SIZE 2 + +uint16_t near_tlv_length(uint8_t *tlv); +uint8_t *near_tlv_next(uint8_t *tlv); +uint8_t *near_tlv_data(uint8_t *tlv); +GList *near_tlv_parse(uint8_t *tlv, size_t tlv_length); + +#endif
diff --git a/neard/include/types.h b/neard/include/types.h new file mode 100644 index 0000000..c4a8d6a --- /dev/null +++ b/neard/include/types.h
@@ -0,0 +1,168 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NEAR_TYPES_H +#define __NEAR_TYPES_H + +#include <byteswap.h> + +#define near_get_unaligned(ptr) \ +({ \ + struct __attribute__((packed)) { \ + typeof(*(ptr)) __v; \ + } *__p = (typeof(__p)) (ptr); \ + __p->__v; \ +}) + +#define near_put_unaligned(val, ptr) \ +do { \ + struct __attribute__((packed)) { \ + typeof(*(ptr)) __v; \ + } *__p = (typeof(__p)) (ptr); \ + __p->__v = (val); \ +} while (0) + +#if __BYTE_ORDER == __LITTLE_ENDIAN +static inline uint64_t near_get_le64(const void *ptr) +{ + return near_get_unaligned((const uint64_t *) ptr); +} + +static inline uint64_t near_get_be64(const void *ptr) +{ + return bswap_64(near_get_unaligned((const uint64_t *) ptr)); +} + +static inline uint32_t near_get_le32(const void *ptr) +{ + return near_get_unaligned((const uint32_t *) ptr); +} + +static inline uint32_t near_get_be32(const void *ptr) +{ + return bswap_32(near_get_unaligned((const uint32_t *) ptr)); +} + +static inline uint16_t near_get_le16(const void *ptr) +{ + return near_get_unaligned((const uint16_t *) ptr); +} + +static inline uint16_t near_get_be16(const void *ptr) +{ + return bswap_16(near_get_unaligned((const uint16_t *) ptr)); +} + +static inline void near_put_le64(uint64_t val, const void *ptr) +{ + near_put_unaligned(val, (uint64_t *) ptr); +} + +static inline void near_put_be64(uint64_t val, const void *ptr) +{ + near_put_unaligned(bswap_64(val), (uint64_t *) ptr); +} + +static inline void near_put_le32(uint32_t val, const void *ptr) +{ + near_put_unaligned(val, (uint32_t *) ptr); +} + +static inline void near_put_be32(uint32_t val, const void *ptr) +{ + near_put_unaligned(bswap_32(val), (uint32_t *) ptr); +} + +static inline void near_put_le16(uint16_t val, const void *ptr) +{ + near_put_unaligned(val, (uint16_t *) ptr); +} + +static inline void near_put_be16(uint16_t val, const void *ptr) +{ + near_put_unaligned(bswap_16(val), (uint16_t *) ptr); +} + +#elif __BYTE_ORDER == __BIG_ENDIAN +static inline uint64_t near_get_le64(const void *ptr) +{ + return bswap_64(near_get_unaligned((const uint64_t *) ptr)); +} + +static inline uint64_t near_get_be64(const void *ptr) +{ + return near_get_unaligned((const uint64_t *) ptr); +} + +static inline uint32_t near_get_le32(const void *ptr) +{ + return bswap_32(near_get_unaligned((const uint32_t *) ptr)); +} + +static inline uint32_t near_get_be32(const void *ptr) +{ + return near_get_unaligned((const uint32_t *) ptr); +} + +static inline uint16_t near_get_le16(const void *ptr) +{ + return bswap_16(near_get_unaligned((const uint16_t *) ptr)); +} + +static inline uint16_t near_get_be16(const void *ptr) +{ + return near_get_unaligned((const uint16_t *) ptr); +} + +static inline void near_put_le64(uint64_t val, const void *ptr) +{ + near_put_unaligned(bswap_64(val), (uint64_t *) ptr); +} + +static inline void near_put_be64(uint64_t val, const void *ptr) +{ + near_put_unaligned(val, (uint64_t *) ptr); +} + +static inline void near_put_le32(uint32_t val, const void *ptr) +{ + near_put_unaligned(bswap_32(val), (uint32_t *) ptr); +} + +static inline void near_put_be32(uint32_t val, const void *ptr) +{ + near_put_unaligned(val, (uint32_t *) ptr); +} + +static inline void near_put_le16(uint16_t val, const void *ptr) +{ + near_put_unaligned(bswap_16(val), (uint16_t *) ptr); +} + +static inline void near_put_be16(uint16_t val, const void *ptr) +{ + near_put_unaligned(val, (uint16_t *) ptr); +} +#else +#error "Unknown byte order" +#endif + +#endif
diff --git a/neard/include/version.h.in b/neard/include/version.h.in new file mode 100644 index 0000000..2119dcc --- /dev/null +++ b/neard/include/version.h.in
@@ -0,0 +1,35 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NEAR_VERSION_H +#define __NEAR_VERSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define NEAR_VERSION "@VERSION@" + +#ifdef __cplusplus +} +#endif + +#endif /* __NEAR_VERSION_H */
diff --git a/neard/install-sh b/neard/install-sh new file mode 100755 index 0000000..377bb86 --- /dev/null +++ b/neard/install-sh
@@ -0,0 +1,527 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2011-11-20.07; # 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 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + 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 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + 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 + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 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 problematic for 'test' and other utilities. + 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 + + # 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-writable 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 X"$d" = X && 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:
diff --git a/neard/ltmain.sh b/neard/ltmain.sh new file mode 100644 index 0000000..a356aca --- /dev/null +++ b/neard/ltmain.sh
@@ -0,0 +1,9661 @@ + +# libtool (GNU libtool) 2.4.2 +# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 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. + +# 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) +# --no-warn don't display warning messages +# --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.2 Debian-2.4.2-1.7ubuntu1 +# automake: $automake_version +# autoconf: $autoconf_version +# +# Report bugs to <bug-libtool@gnu.org>. +# GNU libtool home page: <http://www.gnu.org/software/libtool/>. +# General help using GNU software: <http://www.gnu.org/gethelp/>. + +PROGRAM=libtool +PACKAGE=libtool +VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1" +TIMESTAMP="" +package_revision=1.3337 + +# 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'} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${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=${PATH_SEPARATOR-:} + 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-automake} --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(${AUTOCONF-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_warning=: +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-warning|--no-warn) + opt_warning=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 <<EOF +# $write_libobj - a libtool object file +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object=$write_lobj + +# Name of the non-PIC object +non_pic_object=$write_oldobj + +EOF + $MV "${write_libobj}T" "${write_libobj}" + } +} + + +################################################## +# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # +################################################## + +# func_convert_core_file_wine_to_w32 ARG +# Helper function used by file name 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. +# +# ARG is the $build file name to be converted to w32 format. +# Result is available in $func_convert_core_file_wine_to_w32_result, and will +# be empty on error (or when ARG is empty) +func_convert_core_file_wine_to_w32 () +{ + $opt_debug + func_convert_core_file_wine_to_w32_result="$1" + if test -n "$1"; then + # Unfortunately, winepath does not exit with a non-zero error code, so we + # are forced to check the contents of stdout. On the other hand, if the + # command is not found, the shell will set an exit code of 127 and print + # *an error message* to stdout. So we must check for both error code of + # zero AND non-empty stdout, which explains the odd construction: + func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/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 | *.go | *.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_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + + func_show_eval "$install_prog \$file \$oldlib" 'exit $?' + + if test -n "$stripme" && test -n "$old_striplib"; then + func_show_eval "$old_striplib $tool_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 <import library>. + $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 >/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 () +{ + case \" \$* \" in + *\\ --lt-*) + for lt_wr_arg + do + case \$lt_wr_arg in + --lt-*) ;; + *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; + esac + shift + done ;; + esac + 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 <<EOF + +/* $cwrappersource - temporary wrapper executable 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 executable should never be moved out of the build directory. + If it is, it will not operate correctly. +*/ +EOF + cat <<"EOF" +#ifdef _MSC_VER +# define _CRT_SECURE_NO_DEPRECATE 1 +#endif +#include <stdio.h> +#include <stdlib.h> +#ifdef _MSC_VER +# include <direct.h> +# include <process.h> +# include <io.h> +#else +# include <unistd.h> +# include <stdint.h> +# ifdef __CYGWIN__ +# include <io.h> +# endif +#endif +#include <malloc.h> +#include <stdarg.h> +#include <assert.h> +#include <string.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <sys/stat.h> + +/* 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 <<EOF +volatile const char * MAGIC_EXE = "$magic_exe"; +const char * LIB_PATH_VARNAME = "$shlibpath_var"; +EOF + + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + func_to_host_path "$temp_rpath" + cat <<EOF +const char * LIB_PATH_VALUE = "$func_to_host_path_result"; +EOF + else + cat <<"EOF" +const char * LIB_PATH_VALUE = ""; +EOF + fi + + if test -n "$dllsearchpath"; then + func_to_host_path "$dllsearchpath:" + cat <<EOF +const char * EXE_PATH_VARNAME = "PATH"; +const char * EXE_PATH_VALUE = "$func_to_host_path_result"; +EOF + else + cat <<"EOF" +const char * EXE_PATH_VARNAME = ""; +const char * EXE_PATH_VALUE = ""; +EOF + fi + + if test "$fast_install" = yes; then + cat <<EOF +const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ +EOF + else + cat <<EOF +const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ +EOF + fi + + + cat <<"EOF" + +#define LTWRAPPER_OPTION_PREFIX "--lt-" + +static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; +static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; +static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; + +int +main (int argc, char *argv[]) +{ + char **newargz; + int newargc; + char *tmp_pathspec; + char *actual_cwrapper_path; + char *actual_cwrapper_name; + char *target_name; + char *lt_argv_zero; + intptr_t rval = 127; + + int i; + + program_name = (char *) xstrdup (base_name (argv[0])); + newargz = XMALLOC (char *, argc + 1); + + /* very simple arg parsing; don't want to rely on getopt + * also, copy all non cwrapper options to newargz, except + * argz[0], which is handled differently + */ + newargc=0; + for (i = 1; i < argc; i++) + { + if (strcmp (argv[i], dumpscript_opt) == 0) + { +EOF + case "$host" in + *mingw* | *cygwin* ) + # make stdout use "unix" line endings + echo " setmode(1,_O_BINARY);" + ;; + esac + + cat <<"EOF" + lt_dump_script (stdout); + return 0; + } + if (strcmp (argv[i], debug_opt) == 0) + { + lt_debug = 1; + continue; + } + if (strcmp (argv[i], ltwrapper_option_prefix) == 0) + { + /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX + namespace, but it is not one of the ones we know about and + have already dealt with, above (inluding dump-script), then + report an error. Otherwise, targets might begin to believe + they are allowed to use options in the LTWRAPPER_OPTION_PREFIX + namespace. The first time any user complains about this, we'll + need to make LTWRAPPER_OPTION_PREFIX a configure-time option + or a configure.ac-settable value. + */ + lt_fatal (__FILE__, __LINE__, + "unrecognized %s option: '%s'", + ltwrapper_option_prefix, argv[i]); + } + /* otherwise ... */ + newargz[++newargc] = xstrdup (argv[i]); + } + newargz[++newargc] = NULL; + +EOF + cat <<EOF + /* The GNU banner must be the first non-error debug message */ + lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); +EOF + cat <<"EOF" + lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); + lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); + + tmp_pathspec = find_executable (argv[0]); + if (tmp_pathspec == NULL) + lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); + lt_debugprintf (__FILE__, __LINE__, + "(main) found exe (before symlink chase) at: %s\n", + tmp_pathspec); + + actual_cwrapper_path = chase_symlinks (tmp_pathspec); + lt_debugprintf (__FILE__, __LINE__, + "(main) found exe (after symlink chase) at: %s\n", + actual_cwrapper_path); + XFREE (tmp_pathspec); + + actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); + strendzap (actual_cwrapper_path, actual_cwrapper_name); + + /* wrapper name transforms */ + strendzap (actual_cwrapper_name, ".exe"); + tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); + XFREE (actual_cwrapper_name); + actual_cwrapper_name = tmp_pathspec; + tmp_pathspec = 0; + + /* target_name transforms -- use actual target program name; might have lt- prefix */ + target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); + strendzap (target_name, ".exe"); + tmp_pathspec = lt_extend_str (target_name, ".exe", 1); + XFREE (target_name); + target_name = tmp_pathspec; + tmp_pathspec = 0; + + lt_debugprintf (__FILE__, __LINE__, + "(main) libtool target name: %s\n", + target_name); +EOF + + cat <<EOF + newargz[0] = + XMALLOC (char, (strlen (actual_cwrapper_path) + + strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); + strcpy (newargz[0], actual_cwrapper_path); + strcat (newargz[0], "$objdir"); + strcat (newargz[0], "/"); +EOF + + cat <<"EOF" + /* stop here, and copy so we don't have to do this twice */ + tmp_pathspec = xstrdup (newargz[0]); + + /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ + strcat (newargz[0], actual_cwrapper_name); + + /* DO want the lt- prefix here if it exists, so use target_name */ + lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); + XFREE (tmp_pathspec); + tmp_pathspec = NULL; +EOF + + case $host_os in + mingw*) + cat <<"EOF" + { + char* p; + while ((p = strchr (newargz[0], '\\')) != NULL) + { + *p = '/'; + } + while ((p = strchr (lt_argv_zero, '\\')) != NULL) + { + *p = '/'; + } + } +EOF + ;; + esac + + cat <<"EOF" + XFREE (target_name); + XFREE (actual_cwrapper_path); + XFREE (actual_cwrapper_name); + + lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ + lt_setenv ("DUALCASE", "1"); /* for MSK sh */ + /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must + be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) + because on Windows, both *_VARNAMEs are PATH but uninstalled + libraries must come first. */ + lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); + lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); + + lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", + nonnull (lt_argv_zero)); + for (i = 0; i < newargc; i++) + { + lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", + i, nonnull (newargz[i])); + } + +EOF + + case $host_os in + mingw*) + cat <<"EOF" + /* execv doesn't actually work on mingw as expected on unix */ + newargz = prepare_spawn (newargz); + rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); + if (rval == -1) + { + /* failed to start process */ + lt_debugprintf (__FILE__, __LINE__, + "(main) failed to launch target \"%s\": %s\n", + lt_argv_zero, nonnull (strerror (errno))); + return 127; + } + return rval; +EOF + ;; + *) + cat <<"EOF" + execv (lt_argv_zero, newargz); + return rval; /* =127, but avoids unused variable warning */ +EOF + ;; + esac + + cat <<"EOF" +} + +void * +xmalloc (size_t num) +{ + void *p = (void *) malloc (num); + if (!p) + lt_fatal (__FILE__, __LINE__, "memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), + string) : NULL; +} + +const char * +base_name (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha ((unsigned char) name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return base; +} + +int +check_executable (const char *path) +{ + struct stat st; + + lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", + nonempty (path)); + if ((!path) || (!*path)) + return 0; + + if ((stat (path, &st) >= 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 -n -e ' +s/^\(.\{79\}\)\(..*\)/\1\ +\2/ +h +s/\([\\"]\)/\\\1/g +s/$/\\n/ +s/\([^\n]*\).*/ fputs ("\1", f);/p +g +D' + 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|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + 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|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) + 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$absdir" + # 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 + # correct linux to gnu/linux during the next big refactor + 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) # correct to gnu/linux during the next big refactor + 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 <<EOF + int main() { return 0; } +EOF + $opt_dry_run || $RM conftest + if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then + ldd_output=`ldd conftest` + for i in $deplibs; do + case $i in + -l*) + func_stripname -l '' "$i" + name=$func_stripname_result + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + func_append newdeplibs " $i" + i="" + ;; + esac + fi + if test -n "$i" ; then + libname=`eval "\\$ECHO \"$libname_spec\""` + deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` + set dummy $deplib_matches; shift + deplib_match=$1 + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + func_append newdeplibs " $i" + else + droppeddeps=yes + echo + $ECHO "*** Warning: dynamic linker does not accept needed library $i." + 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 I believe you do not have" + echo "*** because a test_compile did reveal that the linker did not use it for" + echo "*** its dynamic dependency list that programs get resolved with at runtime." + fi + fi + ;; + *) + func_append newdeplibs " $i" + ;; + esac + done + else + # Error occurred in the first compile. Let's try to salvage + # the situation: Compile a separate program for each library. + for i in $deplibs; do + case $i in + -l*) + func_stripname -l '' "$i" + name=$func_stripname_result + $opt_dry_run || $RM conftest + if $LTCC $LTCFLAGS -o conftest conftest.c $i; then + ldd_output=`ldd conftest` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + func_append newdeplibs " $i" + i="" + ;; + esac + fi + if test -n "$i" ; then + libname=`eval "\\$ECHO \"$libname_spec\""` + deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` + set dummy $deplib_matches; shift + deplib_match=$1 + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + func_append newdeplibs " $i" + else + droppeddeps=yes + echo + $ECHO "*** Warning: dynamic linker does not accept needed library $i." + 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 a test_compile did reveal that the linker did not use this one" + echo "*** as a dynamic dependency that programs can get resolved with at runtime." + fi + fi + else + droppeddeps=yes + echo + $ECHO "*** Warning! Library $i is needed by this library but I was not able to" + echo "*** make it link in! You will probably need to install it or some" + echo "*** library that it depends on before this library will be fully" + echo "*** functional. Installing it before continuing would be even better." + fi + ;; + *) + func_append newdeplibs " $i" + ;; + esac + done + fi + ;; + file_magic*) + set dummy $deplibs_check_method; shift + file_magic_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\""` + if test -n "$file_magic_glob"; then + libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` + else + libnameglob=$libname + fi + test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + if test "$want_nocaseglob" = yes; then + shopt -s nocaseglob + potential_libs=`ls $i/$libnameglob[.-]* 2>/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 + # Remove ${wl} instances when linking with ld. + # FIXME: should test the right _cmds variable. + case $archive_cmds in + *\$LD\ *) wl= ;; + esac + 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_append perm_rpath " $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + 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 + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result + 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" + func_resolve_sysroot "$deplib" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` + 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 +
diff --git a/neard/m4/libtool.m4 b/neard/m4/libtool.m4 new file mode 100644 index 0000000..d7c043f --- /dev/null +++ b/neard/m4/libtool.m4
@@ -0,0 +1,7997 @@ +# 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, 2011 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, 2011 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([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +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: +# +# <var>='`$ECHO "$<var>" | $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 <bug-libtool@gnu.org>." + +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) 2011 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)], + [Go], [_LT_LANG(GO)], + [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 + + +m4_ifndef([AC_PROG_GO], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + +# _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([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + +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 there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 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 -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; 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([TAG]) +# --------------------------------- +# 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\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) + 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*|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*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*) + 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" + ;; + powerpcle-*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*) + 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 + ;; +*-*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*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; + *) + 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 \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_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 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + 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" && \ + test undefined != "$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"`env 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 <dlfcn.h> +#endif + +#include <stdio.h> + +#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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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<name>.so + # instead of lib<name>.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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 + ;; + +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[[23]].*) 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 + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 # correct to gnu/linux during the next big refactor + 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 </dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break + ;; + *) + test "$with_gnu_ld" != yes && break + ;; + esac + fi + done + IFS="$lt_save_ifs" +else + lt_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$lt_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +_LT_PATH_LD_GNU +AC_SUBST([LD]) + +_LT_TAGDECL([], [LD], [1], [The linker used to build libraries]) +])# LT_PATH_LD + +# Old names: +AU_ALIAS([AM_PROG_LD], [LT_PATH_LD]) +AU_ALIAS([AC_PROG_LD], [LT_PATH_LD]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_LD], []) +dnl AC_DEFUN([AC_PROG_LD], []) + + +# _LT_PATH_LD_GNU +#- -------------- +m4_defun([_LT_PATH_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 </dev/null` in +*GNU* | *'with BFD'*) + lt_cv_prog_gnu_ld=yes + ;; +*) + lt_cv_prog_gnu_ld=no + ;; +esac]) +with_gnu_ld=$lt_cv_prog_gnu_ld +])# _LT_PATH_LD_GNU + + +# _LT_CMD_RELOAD +# -------------- +# find reload flag for linker +# -- PORTME Some linkers may need a different reload flag. +m4_defun([_LT_CMD_RELOAD], +[AC_CACHE_CHECK([for $LD option to reload object files], + lt_cv_ld_reload_flag, + [lt_cv_ld_reload_flag='-r']) +reload_flag=$lt_cv_ld_reload_flag +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 +_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl +_LT_TAGDECL([], [reload_cmds], [2])dnl +])# _LT_CMD_RELOAD + + +# _LT_CHECK_MAGIC_METHOD +# ---------------------- +# how to check for library dependencies +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_MAGIC_METHOD], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +AC_CACHE_CHECK([how to recognize dependent libraries], +lt_cv_deplibs_check_method, +[lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given 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 + ;; + +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 glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | 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};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /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 | 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 ' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi + ;; + 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 | 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\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) + # 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\ F* | *Sun*Fortran*) + _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 ' + ;; + *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,' + ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + 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(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) + _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_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 <jrb3@best.com> 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)='${wl}-rpath ${wl}$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(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + _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 + ;; + + # 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_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_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_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 <jrb3@best.com> 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 + ;; + + freebsd2.*) + # 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 + ;; + + 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 | 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 +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF +]) + +_lt_libdeps_save_CFLAGS=$CFLAGS +case "$CC $CFLAGS " in #( +*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; +*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; +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_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_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_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# 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=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# Go 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_GO_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_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + +# 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
diff --git a/neard/m4/ltoptions.m4 b/neard/m4/ltoptions.m4 new file mode 100644 index 0000000..5d9acd8 --- /dev/null +++ b/neard/m4/ltoptions.m4
@@ -0,0 +1,384 @@ +# 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@<:@=PKGS@:>@], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [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])])
diff --git a/neard/m4/ltsugar.m4 b/neard/m4/ltsugar.m4 new file mode 100644 index 0000000..9000a05 --- /dev/null +++ b/neard/m4/ltsugar.m4
@@ -0,0 +1,123 @@ +# 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 +])
diff --git a/neard/m4/ltversion.m4 b/neard/m4/ltversion.m4 new file mode 100644 index 0000000..07a8602 --- /dev/null +++ b/neard/m4/ltversion.m4
@@ -0,0 +1,23 @@ +# 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 3337 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.4.2]) +m4_define([LT_PACKAGE_REVISION], [1.3337]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.4.2' +macro_revision='1.3337' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +])
diff --git a/neard/m4/lt~obsolete.m4 b/neard/m4/lt~obsolete.m4 new file mode 100644 index 0000000..c573da9 --- /dev/null +++ b/neard/m4/lt~obsolete.m4
@@ -0,0 +1,98 @@ +# 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])])
diff --git a/neard/missing b/neard/missing new file mode 100755 index 0000000..db98974 --- /dev/null +++ b/neard/missing
@@ -0,0 +1,215 @@ +#! /bin/sh +# Common wrapper for a few potentially missing GNU programs. + +scriptversion=2013-10-28.13; # UTC + +# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 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 <http://www.gnu.org/licenses/>. + +# 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 + +case $1 in + + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; + + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man + +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. + +Send bug reports to <bug-automake@gnu.org>." + 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 + +# Run the given program, remember its exit status. +"$@"; st=$? + +# If it succeeded, we are done. +test $st -eq 0 && exit 0 + +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi + +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'autom4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" + ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} + +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 + +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st + +# 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:
diff --git a/neard/neard.pc.in b/neard/neard.pc.in new file mode 100644 index 0000000..36ee645 --- /dev/null +++ b/neard/neard.pc.in
@@ -0,0 +1,13 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +pkglibdir=@pkglibdir@ +plugindir=@plugindir@ + +Name: neard +Description: NFC daemon +Requires: @GLIB_DEPS@ @DBUS_DEPS@ @NETLINK_DEPS@ +Version: @VERSION@ +Libs: -module -avoid-version -export-symbols-regex neard_plugin_desc +Cflags: -I${includedir}
diff --git a/neard/plugins/handover.c b/neard/plugins/handover.c new file mode 100644 index 0000000..5e46087 --- /dev/null +++ b/neard/plugins/handover.c
@@ -0,0 +1,507 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/types.h> +#include <near/log.h> +#include <near/adapter.h> +#include <near/device.h> +#include <near/tag.h> +#include <near/ndef.h> +#include <near/tlv.h> + +#include "p2p.h" + +#define NDEF_HR_MSG_MIN_LENGTH 0x06 +#define HR_HEADER_SIZE 6 /* header (1) + type len (1) + + * payload len (1) + rec type (2) 'Hx' + * + version (1) + */ + +#define RECORD_TYPE_WKT_ALTERNATIVE_CARRIER 0x0a +#define FRAME_TYPE_OFFSET 3 + +enum loop_stage_flag { + STATE_MAIN_NDEF = 0x00, + STATE_CFG_RECORD = 0x01, +}; + +static GHashTable *hr_ndef_hash = NULL; + +struct extra_ndef { + uint8_t *ndef; + uint8_t length; +}; + +struct hr_ndef { + uint8_t *ndef; + uint16_t cur_ptr; + int cur_record_len; + int missing_bytes; + uint32_t adapter_idx; + uint32_t target_idx; + near_tag_io_cb cb; + int extra_ndef_count; + int block_free_size; + bool cfg_record_state; + bool in_extra_read; +}; + +struct hr_push_client { + uint8_t fd; + uint32_t adapter_idx; + uint32_t target_idx; + near_device_io_cb cb; + guint watch; +}; + +static void free_hr_ndef(gpointer data) +{ + struct hr_ndef *ndef = data; + + if (ndef) + g_free(ndef->ndef); + + g_free(ndef); +} + +static void handover_close(int client_fd, int err, gpointer data) +{ + struct hr_ndef *ndef; + + DBG(""); + + ndef = g_hash_table_lookup(hr_ndef_hash, GINT_TO_POINTER(client_fd)); + if (!ndef) + return; + + g_hash_table_remove(hr_ndef_hash, GINT_TO_POINTER(client_fd)); +} + +/* Parse an incoming handover buffer*/ +static int handover_ndef_parse(int client_fd, struct hr_ndef *ndef) +{ + int err; + GList *records; + struct near_ndef_message *msg = NULL; + + DBG(""); + + if ((!ndef->ndef) || + (ndef->cur_ptr < NDEF_HR_MSG_MIN_LENGTH)) { + err = -EINVAL; + goto fail; + } + + /* call the global parse function */ + records = near_ndef_parse_msg(ndef->ndef, ndef->cur_ptr, &msg); + if (!records) { + err = -ENOMEM; + goto fail; + } + + near_ndef_records_free(records); + + if (msg) { + near_info("Send Hs frame"); + err = send(client_fd, msg->data, msg->length, MSG_DONTWAIT); + + g_free(msg->data); + g_free(msg); + } else { + err = 0; + } + + return err; + +fail: + near_error("ndef parsing failed %d", err); + + handover_close(client_fd, 0, NULL); + + return err; +} + +static bool handover_recv_error(void) +{ + near_error("%s", strerror(errno)); + + if (errno == EAGAIN) + return true; + + return false; +} + +/* Add extra records right after the end of the "Hr" ndef record */ +static bool handover_read_cfg_records(int client_fd, + uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb) +{ + struct hr_ndef *ndef; + uint8_t *new_ndef; + int bytes_recv; + int ndef_size; + int err; + + ndef = g_hash_table_lookup(hr_ndef_hash, GINT_TO_POINTER(client_fd)); + if (!ndef) { + near_error("hr_ndef should exist"); + return false; + } + + if (ndef->in_extra_read) { + /* Next prepare read to complete the Hr */ + new_ndef = g_try_realloc(ndef->ndef, ndef->cur_record_len + + NDEF_HR_MSG_MIN_LENGTH); + if (!new_ndef) + return false; + + ndef->ndef = new_ndef; + + /* Read header bytes */ + bytes_recv = recv(client_fd, ndef->ndef + ndef->cur_ptr, + NDEF_HR_MSG_MIN_LENGTH, MSG_DONTWAIT); + if (bytes_recv < 0) + return handover_recv_error(); + + /* Now, check the ndef payload size plus header bytes */ + ndef_size = near_ndef_record_length(ndef->ndef + ndef->cur_ptr, + bytes_recv); + if (ndef_size < 0) + goto fail; + + ndef->cur_ptr += bytes_recv; + ndef->missing_bytes = ndef_size - bytes_recv; + + /* Next prepare read to complete the NDEF */ + new_ndef = g_try_realloc(ndef->ndef, ndef->cur_record_len + + ndef_size); + if (!new_ndef) + return false; + + ndef->ndef = new_ndef; + + ndef->cur_record_len += ndef_size; + ndef->in_extra_read = false; + + return true; + } + + /* Read remaining bytes */ + bytes_recv = recv(client_fd, ndef->ndef + ndef->cur_ptr, + ndef->missing_bytes, MSG_DONTWAIT); + if (bytes_recv < 0) + return handover_recv_error(); + + ndef->cur_ptr += bytes_recv; + ndef->missing_bytes -= bytes_recv; + + /* Is the NDEF read complete ? */ + if (ndef->missing_bytes) + return true; /* more bytes to come... */ + + if (ndef->extra_ndef_count > 0) + ndef->extra_ndef_count--; + + ndef->in_extra_read = true; + + if (ndef->extra_ndef_count == 0) { + /* All the bytes are read so now, parse the frame */ + err = handover_ndef_parse(client_fd, ndef); + if (err > 0) { + /* clean memory */ + handover_close(client_fd, 0, NULL); + return true; + } + + return false; + } + + /* Process the next NDEF */ + return true; + +fail: + near_error("Handover read NDEFs failed"); + return false; +} + +static bool handover_read_hr(int client_fd, + uint32_t adapter_idx, uint32_t target_idx, near_tag_io_cb cb) +{ + int bytes_recv; + int extra_ndefs; + struct hr_ndef *ndef; + + DBG(""); + + ndef = g_hash_table_lookup(hr_ndef_hash, GINT_TO_POINTER(client_fd)); + if (!ndef) + return false; + + /* Read remaining bytes */ + bytes_recv = recv(client_fd, ndef->ndef + ndef->cur_ptr, + ndef->missing_bytes, MSG_DONTWAIT); + if (bytes_recv < 0) + return handover_recv_error(); + + ndef->cur_ptr += bytes_recv; + ndef->missing_bytes -= bytes_recv; + + /* Is the ndef "Hr" read complete or should we loop */ + if (ndef->missing_bytes) + return true; + + /* + * The first NDEF frame is read. We now should determine how many + * extra records follow the NDEF frame. + * We skip the first 6 bytes (Hr header) to jump on the first record + */ + extra_ndefs = near_ndef_count_records(ndef->ndef + HR_HEADER_SIZE, + ndef->cur_record_len - HR_HEADER_SIZE, + RECORD_TYPE_WKT_ALTERNATIVE_CARRIER); + if (extra_ndefs < 0) + goto fail; + + /* There's still some extra ndefs to read */ + ndef->extra_ndef_count = extra_ndefs; + + /* End of Handover message - now process extra records */ + ndef->in_extra_read = true; + ndef->cfg_record_state = true; + + /* But, if there's no ac record, we jump to the parsing */ + if (ndef->extra_ndef_count == 0) { + handover_ndef_parse(client_fd, ndef); + return false; + } + + return true; + +fail: + near_error("Handover read failed"); + return false; +} + +static bool handover_read_initialize(int client_fd, + uint32_t adapter_idx, uint32_t target_idx, near_tag_io_cb cb) +{ + int bytes_recv; + struct hr_ndef *ndef; + + DBG(""); + + /* Allocate the ndef structure */ + ndef = g_try_malloc0(sizeof(struct hr_ndef)); + if (!ndef) + goto fail; + + /* Allocate and read frame header (6 bytes) */ + ndef->ndef = g_try_malloc0(NDEF_HR_MSG_MIN_LENGTH); + if (!ndef->ndef) + goto fail; + + /* Initialize default values */ + ndef->cur_ptr = 0; + ndef->cur_record_len = -1; + ndef->adapter_idx = adapter_idx; + ndef->target_idx = target_idx; + ndef->cb = cb; + ndef->cfg_record_state = false; + + g_hash_table_insert(hr_ndef_hash, GINT_TO_POINTER(client_fd), ndef); + + /* Read header bytes (6) */ + bytes_recv = recv(client_fd, ndef->ndef, + NDEF_HR_MSG_MIN_LENGTH, MSG_DONTWAIT); + if (bytes_recv < 0) + return handover_recv_error(); + + /* Now, check the ndef payload size plus header bytes */ + ndef->cur_record_len = near_ndef_record_length(ndef->ndef, bytes_recv); + if (ndef->cur_record_len < 0) + goto fail; + + ndef->cur_ptr += bytes_recv; + ndef->missing_bytes = ndef->cur_record_len - bytes_recv; + + if (ndef->cur_record_len == NDEF_HR_MSG_MIN_LENGTH) { + handover_ndef_parse(client_fd, ndef); + return false; + } + + DBG("Handover frame size is %d", ndef->cur_ptr); + + /* Next prepare read to complete the read */ + ndef->ndef = g_try_realloc(ndef->ndef, ndef->cur_record_len); + if (!ndef->ndef) + goto fail; + + return true; + +fail: + free_hr_ndef(ndef); + + return false; +} + +/* + * This function is a "dispatcher", to read Hr/Hs messages, + * and/or additional NDEF messages + */ +static bool handover_read(int client_fd, + uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, + gpointer data) +{ + struct hr_ndef *ndef; + + ndef = g_hash_table_lookup(hr_ndef_hash, GINT_TO_POINTER(client_fd)); + if (!ndef) { + /* First call: allocate and read header bytes */ + return handover_read_initialize(client_fd, adapter_idx, + target_idx, cb); + } + + if (ndef->cfg_record_state) { + return handover_read_cfg_records(client_fd, adapter_idx, + target_idx, cb); + } + + return handover_read_hr(client_fd, adapter_idx, target_idx, cb); +} + +static void free_hr_push_client(struct hr_push_client *client, int status) +{ + DBG(""); + + handover_close(client->fd, 0, NULL); + + if (client->cb) + client->cb(client->adapter_idx, client->target_idx, status); + + if (client->watch > 0) + g_source_remove(client->watch); + + g_free(client); +} + +static gboolean handover_push_event(GIOChannel *channel, + GIOCondition condition, gpointer data) +{ + bool ret; + struct hr_push_client *client = (struct hr_push_client *) data; + + DBG("condition 0x%x", condition); + + if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { + near_error("Error with Handover client"); + + free_hr_push_client(client, -EIO); + + return FALSE; + } + + ret = handover_read(client->fd, + client->adapter_idx, client->target_idx, + client->cb, data); + + if (!ret) + free_hr_push_client(client, 0); + + return ret; +} + +static int handover_push(int client_fd, + uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_device_io_cb cb, + gpointer data) +{ + int err; + struct hr_push_client *client; + GIOChannel *channel; + + DBG(""); + + client = g_try_malloc0(sizeof(struct hr_push_client)); + if (!client) + return -ENOMEM; + + channel = g_io_channel_unix_new(client_fd); + g_io_channel_set_close_on_unref(channel, TRUE); + + client->fd = client_fd; + client->adapter_idx = adapter_idx; + client->target_idx = target_idx; + client->cb = cb; + client->watch = g_io_add_watch(channel, + G_IO_IN | G_IO_HUP | G_IO_NVAL | + G_IO_ERR, handover_push_event, + (gpointer) client); + + g_io_channel_unref(channel); + + err = send(client_fd, ndef->data, ndef->length, MSG_DONTWAIT); + if (err < 0) { + free_hr_push_client(client, err); + g_io_channel_unref(channel); + } + + return err; +} + +struct near_p2p_driver handover_driver = { + .name = "Handover", + .service_name = NEAR_DEVICE_SN_HANDOVER, + .fallback_service_name = NEAR_DEVICE_SN_SNEP, + .sock_type = SOCK_STREAM, + .read = handover_read, + .push = handover_push, + .close = handover_close, +}; + +int handover_init(void) +{ + hr_ndef_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, free_hr_ndef); + + return near_p2p_register(&handover_driver); +} + +void handover_exit(void) +{ + near_p2p_unregister(&handover_driver); + + g_hash_table_destroy(hr_ndef_hash); + hr_ndef_hash = NULL; +}
diff --git a/neard/plugins/llcp-validation.c b/neard/plugins/llcp-validation.c new file mode 100644 index 0000000..853e2ab --- /dev/null +++ b/neard/plugins/llcp-validation.c
@@ -0,0 +1,351 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <near/nfc_copy.h> + +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/device.h> +#include <near/ndef.h> +#include <near/tlv.h> + +#include "p2p.h" + +#define ECHO_DELAY 2000 /* 2 seconds */ + +struct co_cl_client_data { + int fd; + uint8_t buf_count; + GList *sdu_list; + + int miu_len; + uint8_t *miu_buffer; + + int sock_type; + struct sockaddr_nfc_llcp cl_addr; +}; + +struct sdu { + int len; + uint8_t *data; +}; + +typedef bool (*near_incoming_cb) (struct co_cl_client_data *co_client); + +static GHashTable *llcp_client_hash = NULL; + +/* free one SDU */ +static void free_one_sdu(gpointer data) +{ + struct sdu *i_sdu = data; + + if (!i_sdu) + return; + + g_free(i_sdu->data); + g_free(i_sdu); +} + +/* Callback: free sdu data */ +static void llcp_free_client(gpointer data) +{ + struct co_cl_client_data *co_data = data; + + DBG(""); + + if (co_data) { + g_list_free_full(co_data->sdu_list, free_one_sdu); + g_free(co_data->miu_buffer); + } + + g_free(co_data); +} + +static void llcp_send_data(gpointer data, gpointer user_data) +{ + struct co_cl_client_data *clt = user_data; + struct sdu *i_sdu = data; + int err; + + if (!i_sdu) + return; + + /* conn less or oriented ? */ + if (clt->sock_type == SOCK_DGRAM) + err = sendto(clt->fd, i_sdu->data, i_sdu->len, 0, + (struct sockaddr *) &clt->cl_addr, + sizeof(clt->cl_addr)); + else + err = send(clt->fd, i_sdu->data, i_sdu->len, 0); + + if (err < 0) + near_error("Could not send data to client %d", err); + + /* free */ + clt->sdu_list = g_list_remove(clt->sdu_list, i_sdu); + free_one_sdu(i_sdu); + + return; +} + +/* Connexion oriented code */ +static gboolean llcp_common_delay_cb(gpointer user_data) +{ + + struct co_cl_client_data *clt = user_data; + + DBG(""); + + /* process each sdu */ + g_list_foreach(clt->sdu_list, llcp_send_data, user_data); + + clt->buf_count = 0; + + return FALSE; +} + +/* + * Common function: add an incoming SDU to the glist. + * If this is the first SDU, we start a 2 secs timer, and be ready for + * another SDU + */ +static bool llcp_add_incoming_sdu(struct co_cl_client_data *clt, int len) +{ + struct sdu *i_sdu; + + i_sdu = g_try_malloc0(sizeof(struct sdu)); + if (!i_sdu) + goto out_error; + + i_sdu->len = len; + if (len > 0) { + i_sdu->data = g_try_malloc0(len); + if (!i_sdu->data) + goto out_error; + memcpy(i_sdu->data, clt->miu_buffer, len); + } + + clt->sdu_list = g_list_append(clt->sdu_list, i_sdu); + clt->buf_count++; + + /* on the first SDU, fire a 2 seconds timer */ + if (clt->buf_count == 1) + g_timeout_add(ECHO_DELAY, llcp_common_delay_cb, clt); + + return true; + +out_error: + g_free(i_sdu); + return false; +} + +/* + * Connection-less mode. We get a SDU and add it to the the list. We cannot + * acceppt more than 2 SDUs, so we discard subsequent SDU. + * + * */ +static bool llcp_cl_data_recv(struct co_cl_client_data *cl_client) +{ + socklen_t addr_len; + int len; + + DBG(""); + + /* retrieve sdu */ + addr_len = sizeof(struct sockaddr_nfc_llcp); + len = recvfrom(cl_client->fd, cl_client->miu_buffer, cl_client->miu_len, + 0, (struct sockaddr *) &cl_client->cl_addr, &addr_len); + + if (len < 0) { + near_error("Could not read data %d %s", len, strerror(errno)); + return false; + } + + /* Two SDUs max, reject the others */ + if (cl_client->buf_count < 2) + return llcp_add_incoming_sdu(cl_client, len); + else + near_warn("No more than 2 SDU..ignored"); + + return true; +} + +/* + * Connection oriented mode. We get the SDU and add it to the list. + */ +static bool llcp_co_data_recv(struct co_cl_client_data *co_client) +{ + int len; + + DBG(""); + + len = recv(co_client->fd, co_client->miu_buffer, co_client->miu_len, 0); + if (len < 0) { + near_error("Could not read data %d %s", len, strerror(errno)); + return false; + } + return llcp_add_incoming_sdu(co_client, len); + +} + +/* Common function to initialize client connection data */ +static bool llcp_common_read(int client_fd, uint32_t adapter_idx, + uint32_t target_idx, near_tag_io_cb cb, + near_incoming_cb llcp_read_bytes, + const int sock_type) +{ + struct co_cl_client_data *cx_client = NULL; + socklen_t len = sizeof(unsigned int); + + /* Check if this is the 1st call for this client */ + cx_client = g_hash_table_lookup(llcp_client_hash, + GINT_TO_POINTER(client_fd)); + + if (!cx_client) { + cx_client = g_try_malloc0(sizeof(struct co_cl_client_data)); + if (!cx_client) + goto error; + + cx_client->fd = client_fd; + cx_client->sock_type = sock_type; + + /* get MIU */ + if (getsockopt(client_fd, SOL_NFC, NFC_LLCP_MIUX, + &cx_client->miu_len, &len) == 0) + cx_client->miu_len = cx_client->miu_len + + LLCP_DEFAULT_MIU; + else + cx_client->miu_len = LLCP_DEFAULT_MIU; + + cx_client->miu_buffer = g_try_malloc0(cx_client->miu_len); + if (!cx_client->miu_buffer) { + DBG("Cannot allocate MIU buffer (size: %d)", + cx_client->miu_len); + goto error; + } + + /* Add to the client hash table */ + g_hash_table_insert(llcp_client_hash, + GINT_TO_POINTER(client_fd), cx_client); + } + + /* Read the incoming bytes */ + return llcp_read_bytes(cx_client); + +error: + DBG("Memory allocation failed"); + g_free(cx_client); + + return false; +} + +/* clean on close */ +static void llcp_validation_close(int client_fd, int err, gpointer data) +{ + DBG(""); + + /* remove client */ + g_hash_table_remove(llcp_client_hash, GINT_TO_POINTER(client_fd)); +} + +/* Connection Oriented: Wrapper for read function */ +static bool llcp_validation_read_co(int client_fd, uint32_t adapter_idx, + uint32_t target_idx, + near_tag_io_cb cb, + gpointer data) +{ + DBG("CO client with fd: %d", client_fd); + return llcp_common_read(client_fd, adapter_idx, target_idx, cb, + llcp_co_data_recv, SOCK_STREAM); +} + +/* Connection less: Wrapper for read function */ +static bool llcp_validation_read_cl(int client_fd, uint32_t adapter_idx, + uint32_t target_idx, + near_tag_io_cb cb, + gpointer data) +{ + DBG("CL client with fd: %d", client_fd); + return llcp_common_read(client_fd, adapter_idx, target_idx, cb, + llcp_cl_data_recv, SOCK_DGRAM); +} + +/* Connection-less server */ +struct near_p2p_driver validation_llcp_driver_cl = { + .name = "VALIDATION_LLCP_CL", + .service_name = "urn:nfc:sn:cl-echo", + .fallback_service_name = NULL, + .sock_type = SOCK_DGRAM, + .read = llcp_validation_read_cl, + .close = llcp_validation_close, +}; + +/* Connection oriented server */ +struct near_p2p_driver validation_llcp_driver_co = { + .name = "VALIDATION_LLCP_CO", + .service_name = "urn:nfc:sn:co-echo", + .fallback_service_name = NULL, + .sock_type = SOCK_STREAM, + .single_connection = TRUE, + .read = llcp_validation_read_co, + .close = llcp_validation_close, +}; + +int llcp_validation_init(void) +{ + int err; + + DBG(""); + + llcp_client_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, llcp_free_client); + + /* register drivers */ + err = near_p2p_register(&validation_llcp_driver_cl); + if (err < 0) + return err; + + err = near_p2p_register(&validation_llcp_driver_co); + if (err < 0) + near_p2p_unregister(&validation_llcp_driver_cl); + + return err; +} + +void llcp_validation_exit(void) +{ + DBG(""); + + near_p2p_unregister(&validation_llcp_driver_co); + near_p2p_unregister(&validation_llcp_driver_cl); +}
diff --git a/neard/plugins/mifare.c b/neard/plugins/mifare.c new file mode 100644 index 0000000..752dff1 --- /dev/null +++ b/neard/plugins/mifare.c
@@ -0,0 +1,1415 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/tag.h> +#include <near/ndef.h> +#include <near/tlv.h> + +#include <stdio.h> +/* + * NXP Application Notes: + * AN1304, AN1305, ... + * http://www.nxp.com/technical-support-portal/53420/71108/application-notes + */ + +/* Prototypes */ +int mifare_read(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, enum near_tag_sub_type tgt_subtype); + +int mifare_check_presence(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, enum near_tag_sub_type tgt_subtype); + +int mifare_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_tag_io_cb cb, enum near_tag_sub_type tgt_subtype); + +/* MIFARE command set */ +#define MF_CMD_AUTH_KEY_A 0x60 +#define MF_CMD_AUTH_KEY_B 0x61 +#define MF_CMD_WRITE 0xA0 +#define MF_CMD_READ 0x30 + +/* MIFARE commands len including proprietary cmd code */ +#define MF_CMD_AUTH_LEN 0x03 +#define MF_CMD_READ_LEN 0x03 + +/* MIFARE proprietary commands */ +#define MFC_XCHG_DATA_REQ 0x10 +#define MFC_XCHG_DATA_RSP 0x10 +#define MFC_AUTHENTICATE_REQ 0x40 +#define MFC_AUTHENTICATE_RSP 0x40 + +/* MIFARE proprietary commands status */ +#define MFC_AUTH_STATUS_OK 0x00 +#define MFC_AUTH_STATUS_FAILED 0x03 +#define MFC_WRITE_ACK 0x0A + +/* MIFARE Key selector parameters */ +#define MFC_KS_KEY_A 0x00 +#define MFC_KS_KEY_B 0x80 +#define MFC_KS_KEY_PRELOADED 0x00 +#define MFC_KS_KEY_PARAM 0x10 + +#define NFC_AID_TAG 0xE103 + +/* + * Define boundaries for 1K / 2K / 4K + * 1K: sector 0 to 15 (3 blocks each + trailer block ) + * 2K: sector 0 to 31 (3 blocks each + trailer block ) + * 4K: sector 0 to 31 (3 blocks each + trailer block ) + * and sector 32 to 39 (15 blocks each + trailer block ) + */ +#define DEFAULT_BLOCK_SIZE 16 /* MF_CMD_READ */ + +#define STD_BLK_SECT_TRAILER 4 /* bl per sect with trailer 1K/2K */ +#define EXT_BLK_SECT_TRAILER 16 /* bl per sect with trailer 4K */ + +#define STD_BLK_PER_SECT 3 /* 1 sect == 3blocks */ +#define EXT_BLK_PER_SECT 15 /* for 4K tags */ + +/* Usual sector size, including trailer */ +#define STD_SECTOR_SIZE (4 * DEFAULT_BLOCK_SIZE) /* 00-31 */ +#define EXT_SECTOR_SIZE (16 * DEFAULT_BLOCK_SIZE) /* 32-39 */ + +/* Usual sector size, without trailer */ +#define SECTOR_SIZE (3 * DEFAULT_BLOCK_SIZE) +#define BIG_SECTOR_SIZE (15 * DEFAULT_BLOCK_SIZE) + +#define T4K_BOUNDARY 32 +#define T4K_BLK_OFF 0x80 /* blocks count before sector 32 */ + +#define NO_TRAILER 0 +#define WITH_TRAILER 1 +#define SECT_IS_NFC 1 + +/* Default MAD keys. Key length = 6 bytes */ +#define MAD_KEY_LEN 6 +static uint8_t MAD_public_key[] = {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5}; +static uint8_t MAD_NFC_key[] = {0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7}; + +#define MAD1_SECTOR 0x00 /* Sector 0 is for MAD1 */ +#define MAD1_1ST_BLOCK 0x00 /* 1st block of sector 0 */ +#define MAD2_GPB_BITS 0x02 /* MAD v2 flag */ + +#define MAD2_SECTOR 0x10 /* Sector 16 is for MAD2 */ +#define MAD2_1ST_BLOCK 0x40 /* 1st block of MAD2 */ + +#define MAD_V1_AIDS_LEN 15 /* 1 to 0x0F */ +#define MAD_V2_AIDS_LEN 23 /*0x11 to 0x27 */ + +#define NFC_1ST_BLOCK 0x04 /* Sectors from 1 are for NFC */ + +#define ACC_BITS_LEN 3 + +/* Access bits for data blocks mask */ +static uint8_t DATA_access_mask[] = {0x77, 0x77, 0x77}; + +/* Write with key A access bits configuration */ +static uint8_t WRITE_with_key_A[] = {0x77, 0x07, 0x00}; + +/* MAD1 sector structure. Start at block 0x00 */ +struct MAD_1 { + uint8_t man_info[16]; + uint16_t crc_dir; + uint16_t aids[MAD_V1_AIDS_LEN]; + /* Trailer */ + uint8_t key_A[MAD_KEY_LEN]; + uint8_t access_cond[3]; + uint8_t GPB; + uint8_t key_B[MAD_KEY_LEN]; +} __attribute__((packed)); + +/* MAD2 sector structure. Start at block 0x40 */ +struct MAD_2 { + uint16_t crc_dir; + uint16_t aids[MAD_V2_AIDS_LEN]; + /* Trailer */ + uint8_t key_A[MAD_KEY_LEN]; + uint8_t access_cond[3]; + uint8_t GPB; + uint8_t key_B[MAD_KEY_LEN]; +} __attribute__((packed)); + +struct mifare_cookie { + uint32_t adapter_idx; + uint32_t target_idx; + uint8_t *nfcid1; + uint8_t nfcid1_len; + + struct near_tag *tag; + near_tag_io_cb cb; + near_recv next_far_func; + + /* For MAD access */ + struct MAD_1 *mad_1; + struct MAD_2 *mad_2; + GSList *g_sect_list; /* Global sectors list */ + + /* For read and write functions */ + near_recv rws_next_fct; /* next function */ + int rws_block_start; /* first block */ + int rws_block_end; /* last block */ + int rws_completed; /* read blocks */ + + + /* For read only */ + int rs_length; /* read length */ + uint8_t *rs_pmem; /* Stored read sector */ + int rs_max_length; /* available size */ + uint8_t *nfc_data; + size_t nfc_data_length; + + /* For write only */ + struct near_ndef_message *ndef; /* message to write */ + size_t ndef_length; /* message length */ + + /* For access check */ + int (*acc_check_function)(void *data); /* acc check fnc */ + uint8_t *acc_bits_mask; /* blocks to check */ + uint8_t *acc_rights; /* condition */ + int (*acc_denied_fct)(void *data);/* fnc to call on access denial */ + GSList *acc_sect; /* sector from g_sect_list to check */ +}; + +struct type2_cmd { + uint8_t id; + uint8_t cmd; + uint8_t block; + uint8_t data[]; +} __attribute__((packed)); + +/* MFC write data command is done with two steps */ +struct mf_write_prepare_cmd { + uint8_t id; + uint8_t cmd; + uint8_t block; +} __attribute__((packed)); + +struct mf_write_data_cmd { + uint8_t id; + uint8_t data[DEFAULT_BLOCK_SIZE]; +} __attribute__((packed)); + +struct mifare_cmd { + uint8_t cmd; + uint8_t sector; + uint8_t key_selector; + uint8_t key[MAD_KEY_LEN]; + uint8_t nfcid[NFC_NFCID1_MAXSIZE]; +} __attribute__((packed)); + +static int mifare_release(int err, void *data) +{ + struct mifare_cookie *cookie = data; + + DBG("%p", cookie); + + if (!cookie) + return err; + + if (err < 0 && cookie->cb) { + cookie->cb(cookie->adapter_idx, cookie->target_idx, err); + near_adapter_disconnect(cookie->adapter_idx); + } + + /* Now free allocs */ + g_free(cookie->nfcid1); + g_slist_free(cookie->g_sect_list); + g_free(cookie->mad_1); + g_free(cookie->mad_2); + + if (cookie->ndef) + g_free(cookie->ndef->data); + + g_free(cookie->ndef); + g_free(cookie); + cookie = NULL; + + return err; +} + +/* + * Mifare_generic MAD unlock block function + * This function send unlock code to the tag, and so, allow access + * to the complete related sector. + */ +static int mifare_unlock_sector(int block_id, + near_recv next_far_fct, + void *data) +{ + struct mifare_cmd cmd; + struct mifare_cookie *cookie = data; + uint8_t *key_ref; + uint8_t key_selector = 0; + + /* + * For MADs sectors we use public key A (a0a1a2a3a4a5) but + * for NFC sectors we use NFC_KEY_A (d3f7d3f7d3f7) + */ + key_selector = (MFC_KS_KEY_A | MFC_KS_KEY_PARAM); + if (((block_id >= MAD1_1ST_BLOCK) + && (block_id < (MAD1_1ST_BLOCK + STD_BLK_SECT_TRAILER))) + || ((block_id >= MAD2_1ST_BLOCK) + && (block_id < (MAD2_1ST_BLOCK + STD_BLK_SECT_TRAILER)))) + key_ref = MAD_public_key; + else + key_ref = MAD_NFC_key; + + /* CMD AUTHENTICATION */ + cmd.cmd = MFC_AUTHENTICATE_REQ; + + /* Authenticate on sector */ + if (block_id < T4K_BLK_OFF) + cmd.sector = block_id / STD_BLK_SECT_TRAILER; + else + cmd.sector = T4K_BOUNDARY + + ((block_id - T4K_BLK_OFF) / EXT_BLK_SECT_TRAILER); + + /* Configure key selector to use key params */ + /* (don't change preloaded keys) */ + cmd.key_selector = key_selector; + + /* Store the AUTH KEY */ + memcpy(&cmd.key, key_ref, MAD_KEY_LEN); + + /* add the UID */ + memcpy(&cmd.nfcid, cookie->nfcid1, cookie->nfcid1_len); + + return near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + sizeof(cmd) - NFC_NFCID1_MAXSIZE, + next_far_fct, cookie, mifare_release); +} + +/* + * Common MIFARE Block read: + * Each call will read 16 bytes from tag... so to read 1 sector, + * it has to be called it 4 times or 16 times + * (minus 1 or not for the trailer block) + * + * data: mifare_cookie *mf_ck + * mf_ck->read_block: block number to read + */ +static int mifare_read_block(uint8_t block_id, + void *data, + near_recv far_func) +{ + struct mifare_cookie *mf_ck = data; + struct type2_cmd cmd; + + cmd.id = MFC_XCHG_DATA_REQ; + cmd.cmd = MF_CMD_READ; /* MIFARE READ */ + cmd.block = block_id; + + return near_adapter_send(mf_ck->adapter_idx, + (uint8_t *) &cmd, sizeof(cmd), + far_func, mf_ck, mifare_release); +} + +/* + * Check access rights + * Function processes sector trailer received from tag and checks access rights. + * In case specified access isn't granted it calls appropriate + * access denial function. + * If access is granted, previous action (e.g. read, write) is continued. + */ +static int mifare_check_rights_cb(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + uint8_t *c; + int i; + + if (length < 0) { + err = length; + goto out_err; + } + + /* skip reader bytes and key A */ + c = resp + 2 + MAD_KEY_LEN; + + for (i = 0; i < ACC_BITS_LEN; i++) { + if ((c[i] & mf_ck->acc_bits_mask[i]) != mf_ck->acc_rights[i]) { + (*mf_ck->acc_denied_fct)(data); + return 0; + } + } + /* Continue previous action (read/write) */ + err = (*mf_ck->rws_next_fct)(resp, length, data); + + if (err < 0) + goto out_err; + + return err; + +out_err: + return mifare_release(err, mf_ck); +} + +/* Calls to mifare_read_block to get sector trailer */ +static int mifare_check_rights(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + + err = mifare_read_block(mf_ck->rws_block_start, mf_ck, + mifare_check_rights_cb); + + if (err < 0) + return mifare_release(err, mf_ck); + + return err; +} + +static int mifare_read_sector_cb(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err = -1; + + if (length < 0) { + err = length; + goto out_err; + } + + /* Save the data */ + length = length - 1 - 1; /* ignore first byte - Reader byte */ + + /* save the length: */ + mf_ck->rs_length = mf_ck->rs_length + length; + + memcpy(mf_ck->rs_pmem + mf_ck->rws_completed * DEFAULT_BLOCK_SIZE, + resp + 1 + 1,/* ignore reader byte */ + length); + + /* Next block */ + mf_ck->rws_completed = mf_ck->rws_completed + 1; + + if ((mf_ck->rws_block_start + mf_ck->rws_completed) + < mf_ck->rws_block_end) { + err = mifare_read_block( + (mf_ck->rws_block_start + mf_ck->rws_completed), + data, + mifare_read_sector_cb); + } else { + /* Now Process the callback ! */ + if (*mf_ck->rws_next_fct) + err = (*mf_ck->rws_next_fct)(mf_ck->rs_pmem, + mf_ck->rs_length, data); + } + + if ((err < 0) && (err != -ENODATA)) + goto out_err; + + return err; + +out_err: + return mifare_release(err, mf_ck); +} + +static int mifare_read_sector_unlocked(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + + if (length < 0) { + err = length; + goto out_err; + } + /* And run the read process on the first block of the sector */ + err = mifare_read_block(mf_ck->rws_block_start, data, + mifare_read_sector_cb); + + if (err < 0) + goto out_err; + return err; + +out_err: + return mifare_release(err, mf_ck); +} + +/* + * This function reads a complete sector, using block per block function. + * sector sizes can be: + * Sectors 0 to 31: + * 48 bytes: 3*16 no trailer + * 64 bytes: 4*16 with trailer + * Sectors 32 to 39: + * 240 bytes: 15*16 no trailer + * 256 bytes: 16*16 with trailer + * + * Unlock is done at the beginning of first sector. + */ +static int mifare_read_sector(void *cookie, + uint8_t *pmem, /* memory to fill */ + uint16_t memsize, /* remaining free size */ + uint8_t sector_id, /* sector to read */ + bool trailer, /* Add trailer or not */ + near_recv next_func) +{ + struct mifare_cookie *mf_ck = cookie; + int err; + int blocks_count; + + DBG(""); + + /* Prepare call values */ + mf_ck->rs_pmem = pmem; /* where to store */ + mf_ck->rs_max_length = memsize; /* max size to store */ + mf_ck->rs_length = 0; /* no bytes yet */ + mf_ck->rws_completed = 0; /* blocks read */ + + /* According to tag size, compute the correct block offset */ + if (sector_id < T4K_BOUNDARY) + mf_ck->rws_block_start = sector_id * 4; /* 1st block to read */ + else + mf_ck->rws_block_start = + (sector_id - T4K_BOUNDARY) * 16 + T4K_BLK_OFF; + + /* Find blocks_per_sect, according to position and trailer or not */ + if (sector_id < T4K_BOUNDARY) + blocks_count = (STD_BLK_PER_SECT + trailer); + else + blocks_count = (EXT_BLK_PER_SECT + trailer); + + mf_ck->rws_block_end = mf_ck->rws_block_start + blocks_count; + + mf_ck->rws_next_fct = next_func; /* leaving function */ + + /* Being on the first block of a sector, unlock it */ + err = mifare_unlock_sector(mf_ck->rws_block_start, + mifare_read_sector_unlocked, mf_ck); + + return err; +} + +static int mifare_read_NFC_loop(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err = 0; + + DBG(""); + + if (length < 0) { + err = length; + goto out_err; + } + + /* ptr to the next read ptr */ + mf_ck->nfc_data = mf_ck->nfc_data + length; + + /* remaining free mem */ + mf_ck->nfc_data_length = mf_ck->nfc_data_length - length; + + /* Additional sectors to read ? */; + if (g_slist_length(mf_ck->g_sect_list) > 0) { + err = mifare_read_sector(data, /* cookie */ + mf_ck->nfc_data, /* where to store */ + (int) mf_ck->nfc_data_length, /* global length */ + GPOINTER_TO_INT(mf_ck->g_sect_list->data), /* id */ + NO_TRAILER, /* Trailer ? */ + mifare_read_NFC_loop); /* next function */ + + mf_ck->g_sect_list = g_slist_remove(mf_ck->g_sect_list, + mf_ck->g_sect_list->data); + + if (err < 0) + goto out_err; + return err; + } else { + GList *records; + uint8_t *nfc_data; + size_t nfc_data_length; + + DBG("Done reading"); + + nfc_data = near_tag_get_data(mf_ck->tag, &nfc_data_length); + if (!nfc_data) { + err = -ENOMEM; + goto out_err; + } + + records = near_tlv_parse(nfc_data, nfc_data_length); + near_tag_add_records(mf_ck->tag, records, mf_ck->cb, 0); + + err = 0; + } + +out_err: + return mifare_release(err, mf_ck); +} + +/* Prepare read NFC loop */ +static int mifare_read_NFC(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + + /* save tag memory pointer to data_block */ + mf_ck->nfc_data = near_tag_get_data(mf_ck->tag, + &mf_ck->nfc_data_length); + + /* First read here: */ + err = mifare_read_sector(data, /* cookie */ + mf_ck->nfc_data, /* where to store */ + mf_ck->nfc_data_length, /* global length */ + GPOINTER_TO_INT(mf_ck->g_sect_list->data), /* sector id */ + NO_TRAILER, /* Don't want Trailer */ + mifare_read_NFC_loop); /* next function */ + + mf_ck->g_sect_list = g_slist_remove(mf_ck->g_sect_list, + mf_ck->g_sect_list->data); + if (err < 0) + goto out_err; + return err; + +out_err: + return mifare_release(err, mf_ck); +} + +static int mifare_process_MADs(void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + int i; + int global_tag_size = 0; + int ioffset; + uint8_t *tag_data; + size_t data_size; + + DBG(""); + + /* Parse MAD entries to get the global size and fill the array */ + if (!mf_ck->mad_1) { + err = -EINVAL; + goto out_err; + } + + + /* Skip non-NFC sectors at the beginning of the tag, if any */ + for (i = 0 ; i < MAD_V1_AIDS_LEN; i++) { + if (mf_ck->mad_1->aids[i] == NFC_AID_TAG) + break; + } + /* + * NFC sectors have to be continuous, + * so only some sectors at the beginning and at the end of tag + * can be non-NFC. + */ + for (; i < MAD_V1_AIDS_LEN; i++) { + if (mf_ck->mad_1->aids[i] != NFC_AID_TAG) + goto done_mad; + /* Save in the global list */ + mf_ck->g_sect_list = g_slist_append(mf_ck->g_sect_list, + GINT_TO_POINTER(i + 1)); + global_tag_size += SECTOR_SIZE; + } + + /* Now MAD 2 */ + ioffset = MAD_V1_AIDS_LEN + 1 + 1; /* skip 0x10 */ + if (!mf_ck->mad_2) + goto done_mad; + + /* + * If all sectors from MAD1 were non-NFC, + * skip initial non-NFC sectors from MAD2 + */ + + i = 0; + if (global_tag_size == 0) + for (; i < MAD_V2_AIDS_LEN; i++) + if (mf_ck->mad_2->aids[i] == NFC_AID_TAG) + break; + + for (; i < MAD_V2_AIDS_LEN; i++) { + if (mf_ck->mad_2->aids[i] != NFC_AID_TAG) + goto done_mad; + + mf_ck->g_sect_list = g_slist_append(mf_ck->g_sect_list, + GINT_TO_POINTER(ioffset + i)); + if ((ioffset + i) < T4K_BOUNDARY) + global_tag_size += SECTOR_SIZE; + else + global_tag_size += BIG_SECTOR_SIZE; + } +done_mad: + if (global_tag_size == 0) { + + /* no NFC sectors - mark tag as blank */ + near_error("TAG Global size: [%d], not valid NFC tag.", + global_tag_size); + return -ENODEV; + } + + /* n sectors, each sector is 3 blocks, each block is 16 bytes */ + DBG("TAG Global size: [%d]", global_tag_size); + + mf_ck->tag = near_tag_get_tag(mf_ck->adapter_idx, mf_ck->target_idx); + if (!mf_ck->tag) { + err = -ENOMEM; + goto out_err; + } + + /* don't allocate new data before writing */ + tag_data = near_tag_get_data(mf_ck->tag, &data_size); + if (!tag_data) { + err = near_tag_add_data(mf_ck->adapter_idx, + mf_ck->target_idx, + NULL, /* Empty */ + global_tag_size); + + if (err < 0) + goto out_err; + } + + /* Check access rights */ + err = mf_ck->acc_check_function(data); + + if (err < 0) + goto out_err; + + return err; + +out_err: + return mifare_release(err, mf_ck); +} + +/* Transitional function - async */ +static int read_MAD2_complete(uint8_t *empty, int iempty, void *data) +{ + return mifare_process_MADs(data); +} + +/* This function reads the MAD2 sector */ +static int mifare_read_MAD2(void *data) +{ + struct mifare_cookie *mf_ck = data; + int err = 0; + + DBG(""); + + /* As auth is ok, allocate Mifare Access Directory v1 */ + mf_ck->mad_2 = g_try_malloc0(STD_SECTOR_SIZE); + if (!mf_ck->mad_2) { + near_error("Memory allocation failed (MAD2)"); + err = -ENOMEM; + goto out_err; + } + + err = mifare_read_sector(data, + (uint8_t *) mf_ck->mad_2, + (int) STD_SECTOR_SIZE, + MAD2_SECTOR, /* sector 0x10 */ + WITH_TRAILER, /* Want Trailer */ + read_MAD2_complete); + + if (err < 0) + goto out_err; + return err; + +out_err: + return mifare_release(err, mf_ck); +} + +/* + * This function checks, in MAD1, if there's a MAD2 directory + * available. This is is the case for 2K and 4K tag + * If MAD2 exists, read it, elsewhere process the current MAD + */ +static int read_MAD1_complete(uint8_t *empty, int iempty, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + + DBG(""); + + /* Check if there's a need to get MAD2 sector */ + if ((mf_ck->mad_1->GPB & 0x03) == MAD2_GPB_BITS) + err = mifare_read_MAD2(mf_ck); + else + err = mifare_process_MADs(data); + + return err; +} + +/* + * Function called to read the first MAD sector + * MAD is mandatory + */ +static int mifare_read_MAD1(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err = 0; + + DBG("%p %d", data, length); + + if (length < 0) { + err = length; + return err; + } + + /* + * As auth is ok, allocate Mifare Access Directory v1 + * allocated size is also STD_SECTOR_SIZE + */ + mf_ck->mad_1 = g_try_malloc0(STD_SECTOR_SIZE); + if (!mf_ck->mad_1) { + near_error("Memory allocation failed (MAD1)"); + err = -ENOMEM; + goto out_err; + } + + /* Call to mifare_read_sector */ + err = mifare_read_sector(data, + (uint8_t *)mf_ck->mad_1, /* where to store */ + (int) STD_SECTOR_SIZE, /* allocated size */ + MAD1_SECTOR, /* sector 0 */ + WITH_TRAILER, /* Want Trailer */ + read_MAD1_complete); + + if (err < 0) + goto out_err; + return err; + +out_err: + return mifare_release(err, mf_ck); +} + +/* If first NFC sector isn't writable, mark whole tag as read only */ +static int is_read_only(void *data) +{ + struct mifare_cookie *mf_ck = data; + + DBG("Tag is read only"); + + near_tag_set_ro(mf_ck->tag, TRUE); + + /* Continue previous action (read) */ + (*mf_ck->rws_next_fct)(NULL, 0, data); + + return 0; +} + + +static int mifare_check_read_only(void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + + DBG(""); + + /* + * As authorisation with key B is not supported, + * in case writing with key A is not permitted, tag is read-only + */ + mf_ck->acc_bits_mask = DATA_access_mask; + mf_ck->acc_rights = WRITE_with_key_A; + + /* Check acces rights of first NFC sector */ + mf_ck->rws_block_start = NFC_1ST_BLOCK + STD_BLK_PER_SECT; + /* Afterwards read tag */ + mf_ck->rws_next_fct = mifare_read_NFC; + /* In case of writing access denial, set read only */ + mf_ck->acc_denied_fct = is_read_only; + + err = mifare_unlock_sector(mf_ck->rws_block_start, + mifare_check_rights, mf_ck); + + if (err < 0) + return mifare_release(err, mf_ck); + + return err; +} + +/* + * MIFARE: entry point: + * Read all the MAD sectors (0x00, 0x10) to get the Application Directory + * entries. + * On sector 0x00, App. directory is on block 0x01 & block 0x02 + * On sector 0x10, App. directory is on block 0x40, 0x41 & 0x42 + * On reading, CRC is ignored. + */ +int mifare_read(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, enum near_tag_sub_type tgt_subtype) +{ + struct mifare_cookie *cookie; + int err; + + DBG(""); + + /*Check supported and tested Mifare type */ + switch (tgt_subtype) { + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K: + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K: + break; + default: + near_error("Mifare tag type [%d] not supported.", tgt_subtype); + return -1; + } + + /* Alloc global cookie */ + cookie = g_try_malloc0(sizeof(struct mifare_cookie)); + if (!cookie) + return -ENOMEM; + + /* Get the nfcid1 */ + cookie->nfcid1 = near_tag_get_nfcid(adapter_idx, target_idx, + &cookie->nfcid1_len); + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + /* check access rights - while reading just check read only */ + cookie->acc_check_function = mifare_check_read_only; + + /* + * Need to unlock before reading + * This will check if public keys are allowed (and, so, NDEF could + * be "readable"... + */ + err = mifare_unlock_sector(MAD1_1ST_BLOCK, /* related block */ + mifare_read_MAD1, /* callback function */ + cookie); /* target data */ + if (err < 0) + return mifare_release(err, cookie); + + return 0; +} + +static int check_presence(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *cookie = data; + int err = 0; + + DBG("%d", length); + + if (length < 0) { + err = -EIO; + goto out; + } + + if (length == 0) { + err = -ENODATA; + goto out; + } + + if (cookie->cb) + cookie->cb(cookie->adapter_idx, cookie->target_idx, err); +out: + return mifare_release(err, cookie); +} + +int mifare_check_presence(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, enum near_tag_sub_type tgt_subtype) +{ + int err = 0; + struct mifare_cookie *cookie; + + DBG(""); + + /* Check supported and tested Mifare type */ + switch (tgt_subtype) { + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K: + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K: + break; + default: + near_error("Mifare tag type %d not supported.", tgt_subtype); + return -1; + } + + /* Alloc global cookie */ + cookie = g_try_malloc0(sizeof(struct mifare_cookie)); + if (!cookie) + return -ENOMEM; + + /* Get the nfcid1 */ + cookie->nfcid1 = near_tag_get_nfcid(adapter_idx, target_idx, + &cookie->nfcid1_len); + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + /* + * Allocate space to read sector 0 + * allocated size is STD_SECTOR_SIZE + */ + cookie->nfc_data = g_try_malloc0(STD_SECTOR_SIZE); + if (!cookie->nfc_data) { + near_error("Memory allocation failed (STD_SECTOR_SIZE size)"); + return -ENOMEM; + } + + err = mifare_read_sector(cookie, /* cookie */ + cookie->nfc_data, + (int) cookie->nfc_data_length, + 0x00, + WITH_TRAILER, + check_presence); + return err; +} + +static int mifare_write_block_cb(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + struct mf_write_data_cmd cmd; + int err = 0; + + if (length < 0) { + err = length; + goto out_err; + } + + if (resp[2] == MFC_WRITE_ACK) { + /* ACK received, now send data block */ + cmd.id = MFC_XCHG_DATA_REQ; + if ((mf_ck->ndef->offset + DEFAULT_BLOCK_SIZE) < + mf_ck->ndef->length) { + memcpy(cmd.data, mf_ck->ndef->data + + mf_ck->ndef->offset, DEFAULT_BLOCK_SIZE); + mf_ck->ndef->offset += DEFAULT_BLOCK_SIZE; + } else { + memcpy(cmd.data, + mf_ck->ndef->data + mf_ck->ndef->offset, + mf_ck->ndef->length - mf_ck->ndef->offset); + mf_ck->ndef->offset = mf_ck->ndef->length + 1; + } + return near_adapter_send(mf_ck->adapter_idx, + (uint8_t *) &cmd, + DEFAULT_BLOCK_SIZE + 1, + mf_ck->next_far_func, data, NULL); + } else { + /* NAK */ + err = -EIO; + } + +out_err: + return mifare_release(err, mf_ck); +} + +/* + * Common MIFARE Block write: + * Each call will write 16 bytes to tag... so to write 1 sector, + * it has to be called it 4 or 16 times (minus 1 for the trailer block) + */ +static int mifare_write_block(uint8_t block_id, void *data, + near_recv far_func) +{ + struct mf_write_prepare_cmd cmd; + struct mifare_cookie *mf_ck = data; + + cmd.id = MFC_XCHG_DATA_REQ; + cmd.cmd = MF_CMD_WRITE; /* MIFARE WRITE */ + cmd.block = block_id; + + mf_ck->next_far_func = far_func; + return near_adapter_send(mf_ck->adapter_idx, + (uint8_t *) &cmd, sizeof(cmd), + mifare_write_block_cb, data, NULL); +} + +static int mifare_correct_length_cb(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + + DBG("Done writing"); + + if (mf_ck->cb) + mf_ck->cb(mf_ck->adapter_idx, mf_ck->target_idx, 0); + + return mifare_release(0, mf_ck); +} + +/* After writing ndef message, its length has to be updated */ +static int mifare_correct_length(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + + DBG(""); + + /* Correct length field */ + mf_ck->ndef->data[1] = mf_ck->ndef_length; + /* and ndef offset so it points to the beginning */ + mf_ck->ndef->offset = 0; + + /* Run the write process only on the first block of the sector */ + return mifare_write_block(NFC_1ST_BLOCK, mf_ck, + mifare_correct_length_cb); +} + +static int mifare_write_sector_cb(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + + /* Next block */ + mf_ck->rws_completed = mf_ck->rws_completed + 1; + + /* Check if it's the last block */ + if ((mf_ck->rws_block_start + mf_ck->rws_completed) + < mf_ck->rws_block_end) { + /* then check if there's still data to write */ + if (mf_ck->ndef->offset < mf_ck->ndef->length) + err = mifare_write_block( + mf_ck->rws_block_start + mf_ck->rws_completed, + data, mifare_write_sector_cb); + else + /* No more Data to write */ + /* Correct length of the ndef message */ + err = mifare_unlock_sector(NFC_1ST_BLOCK, + mifare_correct_length, mf_ck); + } else { + /* Process the callback */ + err = (*mf_ck->rws_next_fct)(resp, length, data); + } + + if (err < 0) + return mifare_release(err, mf_ck); + + return err; + +} + +static int mifare_write_sector_unlocked(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + + if (length < 0) { + err = length; + goto out_err; + } + + /* Run the write process on the first block of the sector */ + err = mifare_write_block(mf_ck->rws_block_start, data, + mifare_write_sector_cb); + + if (err < 0) + goto out_err; + return err; + +out_err: + return mifare_release(err, mf_ck); +} + +/* + * This function writes a complete sector, using block per block function. + * sector sizes can be: + * Sectors 0 to 31: + * 48 bytes: 3*16 (no trailer) + * Sectors 32 to 39: + * 240 bytes: 15*16 (no trailer) + * + * Unlock is done at the beginning of each sector. + */ +static int mifare_write_sector(void *cookie, + uint8_t sector_id, /* sector to write */ + near_recv next_func) +{ + struct mifare_cookie *mf_ck = cookie; + int blocks_count; + + DBG(""); + + /* Prepare call values */ + + /* According to tag size, compute the correct block offset */ + if (sector_id < T4K_BOUNDARY) + mf_ck->rws_block_start = sector_id * STD_BLK_SECT_TRAILER; + else + mf_ck->rws_block_start = T4K_BLK_OFF + + (sector_id - T4K_BOUNDARY) * EXT_BLK_SECT_TRAILER; + + /* Find blocks_per_sect, according to position, no trailer */ + if (sector_id < T4K_BOUNDARY) + blocks_count = STD_BLK_PER_SECT; + else + blocks_count = EXT_BLK_PER_SECT; + + mf_ck->rws_block_end = mf_ck->rws_block_start + blocks_count; + mf_ck->rws_completed = 0; + mf_ck->rws_next_fct = next_func; + + /* Being on the first block of the sector, unlock it */ + return mifare_unlock_sector(mf_ck->rws_block_start, + mifare_write_sector_unlocked, mf_ck); +} + +static int mifare_write_NFC_loop(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err = 0; + + if (length < 0 || resp[0] != 0) { + err = -EIO; + goto out_err; + } + + /* Something more to write? */; + if (mf_ck->ndef->offset < mf_ck->ndef->length) { + err = mifare_write_sector(data, /* cookie */ + GPOINTER_TO_INT(mf_ck->g_sect_list->data), + mifare_write_NFC_loop); /* next function */ + + mf_ck->g_sect_list = g_slist_remove(mf_ck->g_sect_list, + mf_ck->g_sect_list->data); + + if (err < 0) + goto out_err; + + } else { + /* Correct length of an NDEF message */ + err = mifare_unlock_sector(NFC_1ST_BLOCK, + mifare_correct_length, mf_ck); + + if (err < 0) + goto out_err; + } + + return err; +out_err: + return mifare_release(err, mf_ck); +} + +static int mifare_write_NFC(void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + + DBG(""); + + mf_ck->rws_completed = 0; /* written blocks */ + + /* First write here: */ + err = mifare_write_sector(data, /* cookie */ + GPOINTER_TO_INT(mf_ck->g_sect_list->data), /* sector id */ + mifare_write_NFC_loop); /* next function */ + + mf_ck->g_sect_list = g_slist_remove(mf_ck->g_sect_list, + mf_ck->g_sect_list->data); + + if (err < 0) + return mifare_release(err, mf_ck); + + return err; +} + +static int mifare_check_rights_loop(uint8_t *resp, int length, void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + int sector_id; + + if (mf_ck->acc_sect->next) { + + sector_id = GPOINTER_TO_INT(mf_ck->acc_sect->data); + mf_ck->acc_sect = mf_ck->acc_sect->next; + + if (sector_id < T4K_BOUNDARY) + mf_ck->rws_block_start = sector_id * 4 + + STD_BLK_PER_SECT; + else + mf_ck->rws_block_start = T4K_BLK_OFF + EXT_BLK_PER_SECT + + (sector_id - T4K_BOUNDARY) * 16; + + err = mifare_unlock_sector(mf_ck->rws_block_start, + mifare_check_rights, mf_ck); + } else { + /* Full access granted, start writing */ + err = mifare_write_NFC(data); + } + + if (err < 0) + return mifare_release(err, mf_ck); + + return err; +} + + +/* + * If one of NFC sectors isn't writable, + * tag size for writing is smaller than actual memory size, + * so calculate it and check if it is enough for ndef message. + */ +static int writing_not_permitted(void *data) +{ + struct mifare_cookie *mf_ck = data; + unsigned int new_tag_size = 0; + int sector_id; + int i; + + sector_id = GPOINTER_TO_INT(mf_ck->acc_sect->data); + DBG("Writing sector %i not permitted", sector_id); + + /* Read only sector found, calculate new tag size */ + if (sector_id <= MAD_V1_AIDS_LEN) { + for (i = GPOINTER_TO_INT(mf_ck->g_sect_list->data); + i < sector_id; i++) + new_tag_size += SECTOR_SIZE; + } else { + /* Start from first NFC sector */ + for (i = GPOINTER_TO_INT(mf_ck->g_sect_list->data); + i <= MAD_V1_AIDS_LEN; i++) + new_tag_size += SECTOR_SIZE; + + /* + * If any of previous sector was NFC, skip MAD2 + * If not, leave "i" as it was + */ + if (i < MAD2_SECTOR) + i = MAD2_SECTOR + 1; + + for (; i < sector_id; i++) { + if (i < T4K_BOUNDARY) + new_tag_size += SECTOR_SIZE; + else + new_tag_size += BIG_SECTOR_SIZE; + } + } + + DBG("TAG writable sectors' size: [%d].", new_tag_size); + + /* Check if there's enough space on tag */ + if (new_tag_size < mf_ck->ndef->length) { + near_error("Not enough space on tag"); + + if (mf_ck->cb) + mf_ck->cb(mf_ck->adapter_idx, + mf_ck->target_idx, -ENOSPC); + + mifare_release(0, data); + return -ENOSPC; + } + + /* Enough space on tag, continue writing */ + mifare_write_NFC(data); + + return 0; +} + +static int mifare_check_rights_NFC(void *data) +{ + struct mifare_cookie *mf_ck = data; + int err; + + DBG(""); + + /* + * As authorisation with key B is not supported, + * in case writing with key A is not permitted, tag is read-only + */ + mf_ck->acc_bits_mask = DATA_access_mask; + mf_ck->acc_rights = WRITE_with_key_A; + + mf_ck->acc_sect = mf_ck->g_sect_list; + mf_ck->rws_block_start = NFC_1ST_BLOCK + STD_BLK_PER_SECT; + mf_ck->rws_next_fct = mifare_check_rights_loop; + + mf_ck->acc_denied_fct = writing_not_permitted; + err = mifare_unlock_sector(mf_ck->rws_block_start, + mifare_check_rights, mf_ck); + + if (err < 0) + return mifare_release(err, mf_ck); + + return err; +} + +int mifare_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_tag_io_cb cb, enum near_tag_sub_type tgt_subtype) +{ + struct mifare_cookie *cookie; + struct near_tag *tag; + size_t tag_size; + int err = 0; + + DBG(""); + + /* Check supported and tested Mifare type */ + switch (tgt_subtype) { + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K: + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K: + break; + default: + near_error("Mifare tag type %d not supported.", tgt_subtype); + return -1; + } + + /* Check if there's enough space on tag */ + tag = near_tag_get_tag(adapter_idx, target_idx); + near_tag_get_data(tag, &tag_size); + + if (tag_size < ndef->length) { + near_error("Not enough space on tag"); + return -ENOSPC; + } + + /* Alloc global cookie */ + cookie = g_try_malloc0(sizeof(struct mifare_cookie)); + if (!cookie) + return -ENOMEM; + + /* Get the nfcid1 */ + cookie->nfcid1 = near_tag_get_nfcid(adapter_idx, target_idx, + &cookie->nfcid1_len); + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + cookie->ndef = ndef; + /* Save ndef length */ + cookie->ndef_length = cookie->ndef->data[1]; + cookie->ndef->data[1] = 0; + + /* + * Check if all sectors are writable + * if not, message may be too long to be written + */ + cookie->acc_check_function = mifare_check_rights_NFC; + + /* + * Mifare Classic Tag needs to be unlocked before writing + * This will check if public keys are allowed (NDEF could be "readable") + */ + err = mifare_unlock_sector(MAD1_1ST_BLOCK, /* related block */ + mifare_read_MAD1,/* callback */ + cookie); /* target data */ + + if (err < 0) + return mifare_release(err, cookie); + + return 0; +}
diff --git a/neard/plugins/nfctype1.c b/neard/plugins/nfctype1.c new file mode 100644 index 0000000..600b3d7 --- /dev/null +++ b/neard/plugins/nfctype1.c
@@ -0,0 +1,971 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/tag.h> +#include <near/ndef.h> +#include <near/tlv.h> + +#include <stdio.h> + +#define CMD_READ_ALL 0x00 /* Read seg 0 (incl: HR) */ +#define CMD_READ_SEGS 0x10 /* Read 16 blocks (128 bytes) */ +#define CMD_RID 0x78 /* Read tag UID */ + +#define CMD_WRITE_E 0x53 /* Write with erase */ +#define CMD_WRITE_NE 0x1A /* Write no erase */ + +#define CMD_WRITE_E8 0x54 /* Write 8 bytes with erase */ +#define CMD_WRITE_NE8 0x1B /* Write 8 bytes no erase */ + +#define OFFSET_STATUS_CMD 0x00 +#define OFFSET_HEADER_ROM 0x01 + +#define HR0_TYPE1_STATIC_96B 0x11 +#define HR0_TYPE1_DYNAMIC_512B 0x12 + +#define HR0_TYPE2_HIGH 0x10 +#define HR0_TYPE2_LOW 0x0F + +#define BLOCK_SIZE 8 +#define LEN_STATUS_BYTE 0x01 /* Status byte */ +#define LEN_SPEC_BYTES (LEN_STATUS_BYTE + 0x02) /* HRx */ +#define LEN_UID_BYTES (LEN_STATUS_BYTE + 0x07) /* UID bytes */ +#define LEN_CC_BYTES 0x04 /* Capab. container */ +#define LEN_DYN_BYTES 0x0A /* Bytes CtrlIT and TLV - Dyn. only */ + +#define TYPE1_MAGIC 0xE1 + +#define TAG_T1_DATA_UID(data) ((data) + LEN_SPEC_BYTES) +#define TAG_T1_DATA_CC(data) ((data) + LEN_SPEC_BYTES + LEN_UID_BYTES) +#define TAG_T1_DATA_LENGTH(cc) ((cc[2] + 1) * 8 - LEN_CC_BYTES) + +#define TAG_T1_DATA_NFC(cc) ((cc)[0] & TYPE1_MAGIC) + +#define TYPE1_NOWRITE_ACCESS 0x0F +#define TAG_T1_WRITE_FLAG(cc) ((cc)[3] & TYPE1_NOWRITE_ACCESS) +#define TAG_T1_SEGMENT_SIZE 128 + +/* Max writable data size */ +#define TYPE1_STATIC_MAX_DATA_SIZE_96B 95 +#define TYPE1_STATIC_MAX_DATA_SIZE_512B 469 + +#define UID_LENGTH 4 + +#define TYPE1_TAG_VER_1_1 0x11 +#define TYPE1_TAG_STATIC_SIZE_120 0x0E +#define TYPE1_READ_WRITE_ACCESS 0x00 +#define TYPE1_STATIC_TAG_DATA_LENGTH_96B 116 +#define TYPE1_STATIC_TAG_DATA_LENGTH_512B 508 + +#define RESERVED_BLOCK 0x0D +#define FIRST_DYNAMIC_BLOCK 0x02 + +struct type1_cmd { + uint8_t cmd; + uint8_t addr; + uint8_t data[1]; + uint8_t uid[UID_LENGTH]; +} __attribute__((packed)); + +struct type1_cmd8 { + uint8_t cmd; + uint8_t addr; + uint8_t data[8]; + uint8_t uid[UID_LENGTH]; +} __attribute__((packed)); + +struct type1_cmd_rseg { + uint8_t cmd; + uint8_t addr; + uint8_t data[8]; + uint8_t uid[UID_LENGTH]; +} __attribute__((packed)); + +struct type1_tag { + uint32_t adapter_idx; + uint16_t current_block; + uint16_t current_seg; + uint16_t last_seg; + uint16_t data_read; + uint8_t uid[UID_LENGTH]; + + near_tag_io_cb cb; + struct near_tag *tag; +}; + +struct t1_cookie { + uint32_t adapter_idx; + uint32_t target_idx; + uint8_t uid[UID_LENGTH]; + uint32_t current_block; /* Static tag */ + uint32_t current_byte; /* Static tag */ + struct near_ndef_message *ndef; + near_tag_io_cb cb; + uint8_t cc[LEN_CC_BYTES]; +}; + +enum type1_tag_version { + TYPE1_TAG_UNKNOWN, + TYPE1_TAG_96B, + TYPE1_TAG_512B +} t1_tag_version; + +static void t1_init_cmd(struct type1_tag *tag, struct type1_cmd *cmd) +{ + if (!tag || !cmd) + return; + memcpy(cmd->uid, tag->uid, UID_LENGTH); +} + +static int t1_cookie_release(int err, void *data) +{ + struct t1_cookie *cookie = data; + + DBG("%p", cookie); + + if (!cookie) + return err; + + if (cookie->cb) + cookie->cb(cookie->adapter_idx, cookie->target_idx, err); + + if (cookie->ndef) + g_free(cookie->ndef->data); + + g_free(cookie->ndef); + g_free(cookie); + cookie = NULL; + + return err; +} + +/* Read segments (128 bytes) and store them to the tag data block */ +static int data_recv(uint8_t *resp, int length, void *data) +{ + struct type1_tag *t1_tag = data; + struct type1_cmd t1_cmd; + uint8_t *tagdata; + size_t data_length; + + DBG("%d", length); + + if (length < 0) + return length; + + length = length - LEN_STATUS_BYTE; /* ignore first byte */ + + /* Add data to tag mem */ + tagdata = near_tag_get_data(t1_tag->tag, &data_length); + + /* Check that we have enough free space */ + if (data_length - t1_tag->data_read < (uint)length) + return -EINVAL; + + memcpy(tagdata + t1_tag->data_read, resp + 2, length - LEN_STATUS_BYTE); + + /* Next segment */ + t1_tag->data_read = t1_tag->data_read + length - LEN_STATUS_BYTE; + t1_tag->current_seg = t1_tag->current_seg + 1; + + if (t1_tag->current_seg <= t1_tag->last_seg) { + struct type1_cmd_rseg t1_cmd_rseg; + + /* RSEG cmd */ + t1_init_cmd(t1_tag, &t1_cmd); + t1_cmd_rseg.cmd = CMD_READ_SEGS; + memset(t1_cmd_rseg.data, 0x00, 8); + memcpy(t1_cmd_rseg.uid, t1_cmd.uid, sizeof(t1_cmd.uid)); + t1_cmd_rseg.addr = (t1_tag->current_seg << 4) & 0xFF; + + return near_adapter_send(t1_tag->adapter_idx, + (uint8_t *) &t1_cmd_rseg, sizeof(t1_cmd_rseg), + data_recv, t1_tag, NULL); + } else { /* This is the end */ + GList *records; + + DBG("READ complete"); + + records = near_tlv_parse(tagdata, data_length); + near_tag_add_records(t1_tag->tag, records, t1_tag->cb, 0); + + /* free memory */ + g_free(t1_tag); + + return 0; + } +} + +/* + * The dynamic read function: + * Bytes [0..3] : CC + * [4..8]: TLV Lock ControlIT (0x01, 0x03, v1, V2, V3) + * [9..13]: TLV Reserved Memory Control (0x02, 0x03, V1, V2, V3) + * [14..]: TLV NDEF (0x03, L0, L1, L2, V1,V2 ...) + */ +static int read_dynamic_tag(uint8_t *cc, int length, void *data, + uint8_t tag_mem_size) +{ + struct type1_tag *t1_tag = data; + struct type1_cmd t1_cmd; + struct type1_cmd_rseg t1_cmd_rseg; + uint8_t *tagdata; + uint8_t *pndef; + size_t data_length; + + DBG("Dynamic Mode"); + tagdata = near_tag_get_data(t1_tag->tag, &data_length); + + /* Skip capability container bytes */ + pndef = cc + 14; /* right after CC bytes */ + + /* + * Save first NFC bytes to tag memory + * 10 blocks[0x3..0xC] of 8 bytes + 2 bytes from block 2 + */ + memcpy(tagdata, pndef, 10 * BLOCK_SIZE + 2); + t1_tag->data_read = 10 * BLOCK_SIZE + 2; + + /* Read the next one, up to the end of the data area */ + t1_tag->current_seg = 1; + if (tag_mem_size == HR0_TYPE1_DYNAMIC_512B) + t1_tag->last_seg = 3; + else + return -ENOTSUP; + + + /* RSEG cmd */ + t1_init_cmd(t1_tag, &t1_cmd); + /* T1 read segment */ + t1_cmd_rseg.cmd = CMD_READ_SEGS; + memset(t1_cmd_rseg.data, 0x00, 8); + memcpy(t1_cmd_rseg.uid, t1_cmd.uid, sizeof(t1_cmd.uid)); + /* 5.3.3 ADDS operand is [b8..b5] */ + t1_cmd_rseg.addr = (t1_tag->current_seg << 4) & 0xFF; + + return near_adapter_send(t1_tag->adapter_idx, + (uint8_t *)&t1_cmd_rseg, sizeof(t1_cmd_rseg), + data_recv, t1_tag, NULL); +} + +static int meta_recv(uint8_t *resp, int length, void *data) +{ + struct t1_cookie *cookie = data; + struct near_tag *tag; + struct type1_tag *t1_tag; + uint8_t *cc; + int err = -EOPNOTSUPP; + + DBG("%d", length); + + if (length < 0) { + err = length; + goto out_err; + } + + /* First byte is cmd status */ + if (resp[OFFSET_STATUS_CMD] != 0) { + DBG("Command failed: 0x%x", resp[OFFSET_STATUS_CMD]); + err = -EIO; + goto out_err; + } + + /* Set tag type */ + if (resp[OFFSET_HEADER_ROM] == HR0_TYPE1_STATIC_96B) + t1_tag_version = TYPE1_TAG_96B; + else if (resp[OFFSET_HEADER_ROM] == HR0_TYPE1_DYNAMIC_512B) + t1_tag_version = TYPE1_TAG_512B; + else + t1_tag_version = TYPE1_TAG_UNKNOWN; + + /* Check Magic NFC tag */ + cc = TAG_T1_DATA_CC(resp); + if (TAG_T1_DATA_NFC(cc) == 0) { + if (resp[OFFSET_HEADER_ROM] == HR0_TYPE1_STATIC_96B) { + err = near_tag_add_data(cookie->adapter_idx, + cookie->target_idx, + NULL, + TYPE1_STATIC_TAG_DATA_LENGTH_96B); + } else if (resp[OFFSET_HEADER_ROM] == HR0_TYPE1_DYNAMIC_512B) { + err = near_tag_add_data(cookie->adapter_idx, + cookie->target_idx, + NULL, + TYPE1_STATIC_TAG_DATA_LENGTH_512B); + } else { + near_error("Not a valid NFC magic tag 0x%x", cc[0]); + err = -EINVAL; + goto out_err; + } + } else { + /* Add data to the tag */ + err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx, + NULL, TAG_T1_DATA_LENGTH(cc)); + } + + if (err < 0) + goto out_err; + + tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx); + if (!tag) { + err = -ENOMEM; + goto out_err; + } + + t1_tag = g_try_malloc0(sizeof(struct type1_tag)); + if (!t1_tag) { + err = -ENOMEM; + goto out_err; + } + + t1_tag->adapter_idx = cookie->adapter_idx; + t1_tag->cb = cookie->cb; + t1_tag->tag = tag; + memcpy(t1_tag->uid, cookie->uid, UID_LENGTH); + + /* Set the ReadWrite flag */ + if (TAG_T1_WRITE_FLAG(cc) == TYPE1_NOWRITE_ACCESS) + near_tag_set_ro(tag, TRUE); + else + near_tag_set_ro(tag, FALSE); + + /* Check Static or Dynamic memory model */ + if (resp[OFFSET_HEADER_ROM] == HR0_TYPE1_STATIC_96B) { + uint8_t *tagdata; + size_t data_length; + GList *records; + + if (TAG_T1_DATA_NFC(cc) == 0) + near_tag_set_blank(tag, TRUE); + else + near_tag_set_blank(tag, FALSE); + + DBG("READ Static complete"); + + tagdata = near_tag_get_data(t1_tag->tag, &data_length); + + /* Check that we have enough free space */ + if (data_length < (size_t)TAG_T1_DATA_LENGTH(cc)) + return -EINVAL; + + memcpy(tagdata, cc + LEN_CC_BYTES, TAG_T1_DATA_LENGTH(cc)); + + near_tag_set_memory_layout(tag, NEAR_TAG_MEMORY_STATIC); + + records = near_tlv_parse(tagdata, data_length); + near_tag_add_records(t1_tag->tag, records, t1_tag->cb, 0); + + g_free(t1_tag); + + return 0; + } else if ((resp[OFFSET_HEADER_ROM] & 0xF0) == HR0_TYPE2_HIGH) { + near_tag_set_memory_layout(tag, NEAR_TAG_MEMORY_DYNAMIC); + err = read_dynamic_tag(cc, length, t1_tag, + resp[OFFSET_HEADER_ROM]); + /* + * As reading isn't complete, + * callback shouldn't be called while freeing the cookie + */ + cookie->cb = NULL; + } else { + err = -EOPNOTSUPP; + } + + if (err < 0) + g_free(t1_tag); + +out_err: + DBG("err %d", err); + + return t1_cookie_release(err, cookie); +} + +/* + * READALL to read a maximum of 124 bytes. + * This cmd is common to static and dynamic targets + * This should allow to get the HR0 byte. + */ +static int rid_resp(uint8_t *resp, int length, void *data) +{ + struct t1_cookie *cookie = data; + struct type1_cmd t1_cmd; + uint8_t *uid; + int err; + + DBG(""); + + /* First byte is cmd status */ + if (resp[OFFSET_STATUS_CMD] != 0) { + DBG("Command failed: 0x%x", resp[OFFSET_STATUS_CMD]); + err = -EIO; + goto out_err; + } + + uid = TAG_T1_DATA_UID(resp); + + DBG("UID 0x%x 0x%x 0x%x 0x%x", uid[0], uid[1], uid[2], uid[3]); + + near_tag_set_nfcid(cookie->adapter_idx, cookie->target_idx, + uid, UID_LENGTH); + + t1_cmd.cmd = CMD_READ_ALL; /* Read ALL cmd give 124 bytes */ + t1_cmd.addr = 0; /* NA */ + t1_cmd.data[0] = 0; + memcpy(t1_cmd.uid, uid, UID_LENGTH); + + memcpy(cookie->uid, uid, UID_LENGTH); + + return near_adapter_send(cookie->adapter_idx, + (uint8_t *)&t1_cmd, sizeof(t1_cmd), + meta_recv, cookie, t1_cookie_release); + +out_err: + DBG("err %d", err); + + return t1_cookie_release(err, cookie); +} + +static int nfctype1_read_meta(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, uint8_t *uid) +{ + struct type1_cmd cmd; + struct t1_cookie *cookie; + + DBG(""); + + memset(&cmd, 0, sizeof(cmd)); + + cookie = g_try_malloc0(sizeof(struct t1_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + if (uid) { + cmd.cmd = CMD_READ_ALL; /* Read ALL cmd give 124 bytes */ + memcpy(cmd.uid, uid, UID_LENGTH); + memcpy(cookie->uid, uid, UID_LENGTH); + + return near_adapter_send(adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), meta_recv, cookie, + t1_cookie_release); + } else { + cmd.cmd = CMD_RID; + + return near_adapter_send(adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), rid_resp, cookie, + t1_cookie_release); + } +} + +/* First step: RID to get the tag UID */ +static int nfctype1_read(uint32_t adapter_idx, + uint32_t target_idx, near_tag_io_cb cb) +{ + uint8_t *uid; + uint8_t uid_length; + int err; + + DBG(""); + + t1_tag_version = TYPE1_TAG_UNKNOWN; + uid = near_tag_get_nfcid(adapter_idx, target_idx, &uid_length); + if (!uid || uid_length != UID_LENGTH) { + if (uid) { + near_error("Invalid UID"); + + g_free(uid); + return -EINVAL; + } + + return nfctype1_read_meta(adapter_idx, target_idx, cb, NULL); + } + + err = nfctype1_read_meta(adapter_idx, target_idx, cb, uid); + + g_free(uid); + + return err; +} + +static int write_nmn_e1_resp(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t1_cookie *cookie = data; + + DBG(""); + + if (length < 0) + err = length; + + if (resp[OFFSET_STATUS_CMD] != 0) + err = -EIO; + + DBG("Done writing"); + + return t1_cookie_release(err, cookie); +} + +static int write_nmn_e1(struct t1_cookie *cookie) +{ + struct type1_cmd cmd; + + DBG(""); + + cmd.cmd = CMD_WRITE_E; + cmd.addr = 0x08; + cmd.data[0] = TYPE1_MAGIC; + memcpy(cmd.uid, cookie->uid, UID_LENGTH); + + return near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), write_nmn_e1_resp, cookie, + t1_cookie_release); +} + +static int data_write_resp(uint8_t *resp, int length, void *data) +{ + struct t1_cookie *cookie = data; + struct type1_cmd cmd; + struct type1_cmd8 cmd8; + uint8_t data_block[BLOCK_SIZE]; + uint8_t addr = 0; + int err = -EIO; + + DBG(""); + + if (length < 0) { + err = length; + goto out_err; + } + + if (resp[OFFSET_STATUS_CMD] != 0) { + err = -EIO; + goto out_err; + } + + if (cookie->ndef->offset >= cookie->ndef->length) + return write_nmn_e1(cookie); + + if (t1_tag_version == TYPE1_TAG_96B) { + /* Static */ + if (cookie->current_byte >= BLOCK_SIZE) { + cookie->current_byte = 0; + cookie->current_block++; + } + + cmd.cmd = CMD_WRITE_E; + addr = cookie->current_block << 3; + cmd.addr = addr | (cookie->current_byte & 0x7); + cmd.data[0] = cookie->ndef->data[cookie->ndef->offset]; + memcpy(cmd.uid, cookie->uid, UID_LENGTH); + cookie->ndef->offset++; + cookie->current_byte++; + + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), data_write_resp, cookie, + NULL); + if (err < 0) + goto out_err; + + return err; + } else { + /* Dynamic */ + /* Skip reserved and lock/OTP blocks */ + if (cookie->current_block == RESERVED_BLOCK) + cookie->current_block += 3; + + if ((cookie->ndef->length + - cookie->ndef->offset) >= BLOCK_SIZE) { + if (cookie->current_block == FIRST_DYNAMIC_BLOCK) { + cmd.cmd = CMD_WRITE_E; + cmd.addr = (FIRST_DYNAMIC_BLOCK << 3) + | (cookie->current_byte & 0x7); + cmd.data[0] = + cookie->ndef->data[cookie->ndef->offset]; + memcpy(cmd.uid, cookie->uid, + UID_LENGTH); + cookie->ndef->offset++; + cookie->current_byte++; + if (cookie->current_byte >= BLOCK_SIZE) + cookie->current_block++; + goto send_byte; /* Write 2 first bytes */ + } else { + cmd8.cmd = CMD_WRITE_E8; + cmd8.addr = cookie->current_block; + memcpy(cmd8.data, + &cookie->ndef->data[cookie->ndef->offset], + BLOCK_SIZE); + cookie->ndef->offset += BLOCK_SIZE; + } + } else { + uint8_t remaining_bytes = 0; + + memset(data_block, 0x00, BLOCK_SIZE); + cmd8.cmd = CMD_WRITE_E8; + cmd8.addr = cookie->current_block; + remaining_bytes = cookie->ndef->length + - cookie->ndef->offset; + memcpy(data_block, + &cookie->ndef->data[cookie->ndef->offset], + remaining_bytes); + memcpy(cmd8.data, data_block, BLOCK_SIZE); + cookie->ndef->offset += remaining_bytes; + } + memcpy(cmd8.uid, cookie->uid, UID_LENGTH); + cookie->current_block++; + return near_adapter_send(cookie->adapter_idx, + (uint8_t *)&cmd8, + sizeof(cmd8), data_write_resp, cookie, + t1_cookie_release); + +send_byte: + return near_adapter_send(cookie->adapter_idx, + (uint8_t *)&cmd, + sizeof(cmd), data_write_resp, + cookie, + t1_cookie_release); + } + +out_err: + return t1_cookie_release(err, cookie); +} + +static int data_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, near_tag_io_cb cb) +{ + int err; + struct type1_cmd cmd; + struct t1_cookie *cookie; + uint8_t *uid, uid_length; + + DBG(""); + + uid = near_tag_get_nfcid(adapter_idx, target_idx, &uid_length); + if (!uid || uid_length != UID_LENGTH) { + near_error("Invalid type 1 UID"); + err = -EINVAL; + goto out_err; + } + + cmd.cmd = CMD_WRITE_E; + cmd.data[0] = 0x00; + memcpy(cmd.uid, uid, UID_LENGTH); + + cookie = g_try_malloc0(sizeof(struct t1_cookie)); + if (!cookie) { + g_free(uid); + err = -ENOMEM; + goto out_err; + } + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + memcpy(cookie->uid, uid, UID_LENGTH); + cookie->ndef = ndef; + cookie->cb = cb; + cmd.addr = 0x08; + + if (t1_tag_version == TYPE1_TAG_96B) { + /* Static */ + cookie->current_block = 1; + cookie->current_byte = 4; + } else { + /* Dynamic */ + cookie->current_block = 2; + cookie->current_byte = 6; + } + + g_free(uid); + + return near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), data_write_resp, cookie, + t1_cookie_release); +out_err: + if (cb) + cb(adapter_idx, target_idx, err); + + return err; +} + +/* + * The writing of a new NDEF message SHALL occur as follows: + * Write NMN = 00h to indicate that no valid NDEF message is present + * during writing to allow error detection in the event that the tag + * is removed from the field prior to completion of operation. + * Write VNo and RWA if required + * Write NDEF Message TLV + * Write NDEF Message data + * Write NMN = E1h as the last byte to be written + */ +static int nfctype1_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_tag_io_cb cb) +{ + struct near_tag *tag; + int err; + size_t t1_size = 0; + + DBG(""); + + if (!ndef || !cb) { + err = -EINVAL; + goto out_err; + } + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + /* This check is valid for only static tags. + * Max data length on Type 1 Tag including TLV's + * is TYPE1_STATIC_MAX_DATA_SIZE */ + if (near_tag_get_memory_layout(tag) == NEAR_TAG_MEMORY_STATIC) { + if (t1_tag_version == TYPE1_TAG_96B) + t1_size = TYPE1_STATIC_MAX_DATA_SIZE_96B; + else + t1_size = 0; + + if ((ndef->length + 3) > t1_size) { + near_error("not enough space on tag"); + err = -ENOSPC; + goto out_err; + } + } else if (near_tag_get_memory_layout(tag) == + NEAR_TAG_MEMORY_DYNAMIC) { + if (t1_tag_version == TYPE1_TAG_512B) + t1_size = TYPE1_STATIC_MAX_DATA_SIZE_512B; + else + t1_size = 0; + + if ((ndef->length + 3) > t1_size) { + near_error("not enough space on tag"); + err = -ENOSPC; + goto out_err; + } + } + + return data_write(adapter_idx, target_idx, ndef, cb); + +out_err: + if (cb) + cb(adapter_idx, target_idx, err); + + return err; +} + +static int check_presence(uint8_t *resp, int length, void *data) +{ + struct t1_cookie *cookie = data; + int err = 0; + + DBG("%d", length); + + if (length < 0) + err = -EIO; + + return t1_cookie_release(err, cookie); +} + +static int nfctype1_check_presence(uint32_t adapter_idx, + uint32_t target_idx, near_tag_io_cb cb) +{ + struct type1_cmd t1_cmd; + struct t1_cookie *cookie; + uint8_t *uid, uid_length; + + DBG(""); + + uid = near_tag_get_nfcid(adapter_idx, target_idx, &uid_length); + if (!uid || uid_length != UID_LENGTH) { + near_error("Invalid type 1 UID"); + return -EINVAL; + } + + t1_cmd.cmd = CMD_READ_ALL; /* Read ALL cmd give 124 bytes */ + t1_cmd.addr = 0; /* NA */ + t1_cmd.data[0] = 0; + memcpy(t1_cmd.uid, uid, UID_LENGTH); + + g_free(uid); + + cookie = g_try_malloc0(sizeof(struct t1_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + return near_adapter_send(adapter_idx, (uint8_t *) &t1_cmd, + sizeof(t1_cmd), check_presence, cookie, + t1_cookie_release); +} + +static int format_resp(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t1_cookie *cookie = data; + struct near_tag *tag; + struct type1_cmd cmd; + uint8_t addr; + + DBG(""); + + if (length < 0 || resp[0] != 0) { + err = -EIO; + goto out_err; + } + + if (cookie->current_byte < LEN_CC_BYTES) { + cmd.cmd = CMD_WRITE_E; + addr = cookie->current_block << 3; + cmd.addr = addr | (cookie->current_byte & 0x7); + cmd.data[0] = cookie->cc[cookie->current_byte]; + cookie->current_byte++; + memcpy(cmd.uid, cookie->uid, UID_LENGTH); + + return near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), format_resp, cookie, + t1_cookie_release); + } else { + tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + DBG("Done formatting"); + near_tag_set_blank(tag, FALSE); + } + +out_err: + return t1_cookie_release(err, cookie); +} + +static int nfctype1_format(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb) +{ + int err; + struct near_tag *tag; + struct type1_cmd cmd; + struct t1_cookie *cookie; + uint8_t *uid, uid_length, addr; + + DBG(""); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + return -EINVAL; + + /* TODO: Dynamic tag format */ + if (near_tag_get_memory_layout(tag) != NEAR_TAG_MEMORY_STATIC) + return -EOPNOTSUPP; + + uid = near_tag_get_nfcid(adapter_idx, target_idx, &uid_length); + if (!uid || uid_length != UID_LENGTH) { + near_error("Invalid type 1 UID"); + return -EINVAL; + } + + cookie = g_try_malloc0(sizeof(struct t1_cookie)); + if (!cookie) { + err = -EINVAL; + goto out_err; + } + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + memcpy(cookie->uid, uid, UID_LENGTH); + cookie->cc[0] = TYPE1_MAGIC; + cookie->cc[1] = TYPE1_TAG_VER_1_1; + cookie->cc[2] = TYPE1_TAG_STATIC_SIZE_120; + cookie->cc[3] = TYPE1_READ_WRITE_ACCESS; + cookie->current_block = 1; + cookie->current_byte = 0; + + cmd.cmd = CMD_WRITE_E; + addr = cookie->current_block << 3; + cmd.addr = addr | (cookie->current_byte & 0x7); + cmd.data[0] = cookie->cc[cookie->current_byte]; + cookie->current_byte++; + memcpy(cmd.uid, cookie->uid, UID_LENGTH); + g_free(uid); + + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), format_resp, cookie, + t1_cookie_release); + if (err < 0) + goto out_err; + + return 0; + +out_err: + g_free(cookie); + g_free(uid); + + return err; +} + +static struct near_tag_driver type1_driver = { + .type = NFC_PROTO_JEWEL, + .priority = NEAR_TAG_PRIORITY_DEFAULT, + .read = nfctype1_read, + .write = nfctype1_write, + .check_presence = nfctype1_check_presence, + .format = nfctype1_format, +}; + +static int nfctype1_init(void) +{ + DBG(""); + + return near_tag_driver_register(&type1_driver); +} + +static void nfctype1_exit(void) +{ + DBG(""); + + near_tag_driver_unregister(&type1_driver); +} + +NEAR_PLUGIN_DEFINE(nfctype1, "NFC Forum Type 1 tags support", VERSION, + NEAR_PLUGIN_PRIORITY_HIGH, nfctype1_init, nfctype1_exit)
diff --git a/neard/plugins/nfctype2.c b/neard/plugins/nfctype2.c new file mode 100644 index 0000000..70d6d82 --- /dev/null +++ b/neard/plugins/nfctype2.c
@@ -0,0 +1,639 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/tag.h> +#include <near/ndef.h> +#include <near/tlv.h> + +extern int mifare_read(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, enum near_tag_sub_type tgt_subtype); + +extern int mifare_check_presence(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, enum near_tag_sub_type tgt_subtype); + +extern int mifare_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_tag_io_cb cb, enum near_tag_sub_type tgt_subtype); + +#define CMD_READ 0x30 +#define CMD_READ_SIZE 0x02 + +#define CMD_WRITE 0xA2 + +#define READ_SIZE 16 +#define BLOCK_SIZE 4 + +#define META_BLOCK_START 0 +#define DATA_BLOCK_START 4 +#define TYPE2_MAGIC 0xe1 + +#define TAG_DATA_CC(data) ((data) + 12) +#define TAG_DATA_LENGTH(cc) ((cc)[2] * 8) +#define TAG_DATA_NFC(cc) ((cc)[0] & TYPE2_MAGIC) + +#define TYPE2_NOWRITE_ACCESS 0x0F +#define TYPE2_READWRITE_ACCESS 0x00 +#define TAG_T2_WRITE_FLAG(cc) ((cc)[3] & TYPE2_NOWRITE_ACCESS) + +#define NDEF_MAX_SIZE 0x30 + +#define CC_BLOCK_START 3 +#define TYPE2_TAG_VER_1_0 0x10 +#define TYPE2_DATA_SIZE_48 0x6 + +struct type2_cmd { + uint8_t cmd; + uint8_t block; + uint8_t data[BLOCK_SIZE]; +} __attribute__((packed)); + +struct type2_tag { + uint32_t adapter_idx; + uint16_t current_block; + + near_tag_io_cb cb; + struct near_tag *tag; +}; + +struct t2_cookie { + uint32_t adapter_idx; + uint32_t target_idx; + uint8_t current_block; + struct near_ndef_message *ndef; + near_tag_io_cb cb; +}; + +struct type2_cc { + uint8_t magic; + uint8_t version; + uint8_t mem_size; + uint8_t read_write; +}; + +static int t2_cookie_release(int err, void *data) +{ + struct t2_cookie *cookie = data; + + DBG("%p", cookie); + + if (!cookie) + return err; + + if (cookie->cb) + cookie->cb(cookie->adapter_idx, cookie->target_idx, err); + + if (cookie->ndef) + g_free(cookie->ndef->data); + + g_free(cookie->ndef); + g_free(cookie); + + return err; +} + +static int data_recv(uint8_t *resp, int length, void *data) +{ + struct type2_tag *tag = data; + struct type2_cmd cmd; + uint8_t *nfc_data; + size_t current_length, length_read, data_length; + uint32_t adapter_idx; + int read_blocks; + + DBG("%d", length); + + if (length < 0) { + g_free(tag); + + return length; + } + + nfc_data = near_tag_get_data(tag->tag, &data_length); + adapter_idx = near_tag_get_adapter_idx(tag->tag); + + length_read = length - NFC_HEADER_SIZE; + current_length = tag->current_block * BLOCK_SIZE; + if (current_length + length - NFC_HEADER_SIZE > data_length) + length_read = data_length - current_length; + + memcpy(nfc_data + current_length, resp + NFC_HEADER_SIZE, length_read); + + if (current_length + length_read == data_length) { + GList *records; + + /* TODO parse tag->data for NDEFS, and notify target.c */ + tag->current_block = 0; + + DBG("Done reading"); + + records = near_tlv_parse(nfc_data, data_length); + near_tag_add_records(tag->tag, records, tag->cb, 0); + + g_free(tag); + + return 0; + } + + read_blocks = length / BLOCK_SIZE; + tag->current_block += read_blocks; + + cmd.cmd = CMD_READ; + cmd.block = DATA_BLOCK_START + tag->current_block; + + DBG("adapter %d", adapter_idx); + + return near_adapter_send(adapter_idx, + (uint8_t *) &cmd, CMD_READ_SIZE, + data_recv, tag, NULL); +} + +static int data_read(struct type2_tag *tag) +{ + struct type2_cmd cmd; + uint32_t adapter_idx; + + DBG(""); + + tag->current_block = 0; + + cmd.cmd = CMD_READ; + cmd.block = DATA_BLOCK_START; + + adapter_idx = near_tag_get_adapter_idx(tag->tag); + + return near_adapter_send(adapter_idx, + (uint8_t *) &cmd, CMD_READ_SIZE, + data_recv, tag, NULL); +} + +static int meta_recv(uint8_t *resp, int length, void *data) +{ + struct t2_cookie *cookie = data; + struct near_tag *tag; + struct type2_tag *t2_tag; + uint8_t *cc; + int err; + + DBG("%d", length); + + if (length < 0) { + err = length; + goto out_err; + } + + if (resp[0] != 0) { + err = -EIO; + goto out_err; + } + + cc = TAG_DATA_CC(resp + NFC_HEADER_SIZE); + + /* Default to 48 bytes data size in case of blank tag */ + err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx, + NULL, (TAG_DATA_LENGTH(cc) ? TAG_DATA_LENGTH(cc) : + TYPE2_DATA_SIZE_48 << 3)); + + if (err < 0) + goto out_err; + + tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx); + if (!tag) { + err = -ENOMEM; + goto out_err; + } + + t2_tag = g_try_malloc0(sizeof(struct type2_tag)); + if (!t2_tag) { + err = -ENOMEM; + goto out_err; + } + + t2_tag->adapter_idx = cookie->adapter_idx; + t2_tag->cb = cookie->cb; + t2_tag->tag = tag; + + /* Set the ReadWrite flag */ + if (TAG_T2_WRITE_FLAG(cc) == TYPE2_NOWRITE_ACCESS) + near_tag_set_ro(tag, TRUE); + else + near_tag_set_ro(tag, FALSE); + + near_tag_set_memory_layout(tag, NEAR_TAG_MEMORY_STATIC); + + if (TAG_DATA_NFC(cc) == 0) { + DBG("Mark as blank tag"); + near_tag_set_blank(tag, TRUE); + } else { + near_tag_set_blank(tag, FALSE); + } + + err = data_read(t2_tag); + if (err < 0) + goto out_tag; + + /* + * As reading isn't complete, + * callback shouldn't be called while freeing the cookie + */ + cookie->cb = NULL; + return t2_cookie_release(err, cookie); + +out_tag: + g_free(t2_tag); + +out_err: + return t2_cookie_release(err, cookie); +} + +static int nfctype2_read_meta(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb) +{ + struct type2_cmd cmd; + struct t2_cookie *cookie; + + DBG(""); + + cmd.cmd = CMD_READ; + cmd.block = META_BLOCK_START; + + cookie = g_try_malloc0(sizeof(struct t2_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + return near_adapter_send(adapter_idx, (uint8_t *) &cmd, CMD_READ_SIZE, + meta_recv, cookie, t2_cookie_release); +} + +static int nfctype2_read(uint32_t adapter_idx, + uint32_t target_idx, near_tag_io_cb cb) +{ + enum near_tag_sub_type tgt_subtype; + + DBG(""); + + tgt_subtype = near_tag_get_subtype(adapter_idx, target_idx); + + switch (tgt_subtype) { + case NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT: + return nfctype2_read_meta(adapter_idx, target_idx, cb); + + /* Specific Mifare read access */ + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K: + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K: + return mifare_read(adapter_idx, target_idx, + cb, tgt_subtype); + + default: + DBG("Unknown Tag Type 2 subtype %d", tgt_subtype); + return -1; + } +} + +static int data_write_resp(uint8_t *resp, int length, void *data) +{ + int err; + struct t2_cookie *cookie = data; + struct type2_cmd cmd; + + DBG(""); + + if (length < 0 || resp[0] != 0) { + err = -EIO; + goto out_err; + } + + if (cookie->ndef->offset > cookie->ndef->length) { + DBG("Done writing"); + + return t2_cookie_release(0, cookie); + } + + cmd.cmd = CMD_WRITE; + cmd.block = cookie->current_block; + cookie->current_block++; + + memset(cmd.data,0,BLOCK_SIZE); + + if ((cookie->ndef->offset + BLOCK_SIZE) < + cookie->ndef->length) { + memcpy(cmd.data, cookie->ndef->data + + cookie->ndef->offset, BLOCK_SIZE); + cookie->ndef->offset += BLOCK_SIZE; + } else { + memcpy(cmd.data, cookie->ndef->data + cookie->ndef->offset, + cookie->ndef->length - cookie->ndef->offset); + cookie->ndef->offset = cookie->ndef->length + 1; + } + + return near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), data_write_resp, cookie, + t2_cookie_release); + +out_err: + return t2_cookie_release(err, cookie); +} + +static int data_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_tag_io_cb cb) +{ + struct type2_cmd cmd; + struct t2_cookie *cookie; + int err; + + DBG(""); + + cookie = g_try_malloc0(sizeof(struct t2_cookie)); + if (!cookie) { + err = -ENOMEM; + if (cb) + cb(adapter_idx, target_idx, err); + return err; + } + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->current_block = DATA_BLOCK_START; + cookie->ndef = ndef; + cookie->cb = cb; + + cmd.cmd = CMD_WRITE; + cmd.block = cookie->current_block; + memcpy(cmd.data, cookie->ndef->data, BLOCK_SIZE); + cookie->ndef->offset += BLOCK_SIZE; + cookie->current_block++; + + return near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), data_write_resp, cookie, + t2_cookie_release); +} + +static int nfctype2_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_tag_io_cb cb) +{ + struct near_tag *tag; + enum near_tag_sub_type tgt_subtype; + int err; + + DBG(""); + + if (!ndef || !cb) { + err = -EINVAL; + goto out_err; + } + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + tgt_subtype = near_tag_get_subtype(adapter_idx, target_idx); + + switch (tgt_subtype) { + case NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT: + /* + * This check is valid for only static tags. + * Max data length on Type 2 Tag + * including TLV's is NDEF_MAX_SIZE + */ + if (near_tag_get_memory_layout(tag) == NEAR_TAG_MEMORY_STATIC) { + if ((ndef->length) > near_tag_get_data_length(tag)) { + near_error("Not enough space on tag %zd %zd", + ndef->length, + near_tag_get_data_length(tag)); + err = -ENOSPC; + goto out_err; + } + } + + return data_write(adapter_idx, target_idx, ndef, cb); + + /* Specific Mifare write access */ + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K: + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K: + return mifare_write(adapter_idx, target_idx, ndef, + cb, tgt_subtype); + default: + DBG("Unknown TAG Type 2 subtype %d", tgt_subtype); + err = -EINVAL; + goto out_err; + } + + return 0; + +out_err: + if (cb) + cb(adapter_idx, target_idx, err); + + return err; +} + +static int check_presence(uint8_t *resp, int length, void *data) +{ + struct t2_cookie *cookie = data; + int err = 0; + + DBG("%d", length); + + if (length < 0) + err = -EIO; + + return t2_cookie_release(err, cookie); +} + +static int nfctype2_check_presence(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb) +{ + struct type2_cmd cmd; + struct t2_cookie *cookie; + enum near_tag_sub_type tgt_subtype; + + DBG(""); + + tgt_subtype = near_tag_get_subtype(adapter_idx, target_idx); + + switch (tgt_subtype) { + case NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT: + cmd.cmd = CMD_READ; + cmd.block = META_BLOCK_START; + + cookie = g_try_malloc0(sizeof(struct t2_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + return near_adapter_send(adapter_idx, (uint8_t *) &cmd, + CMD_READ_SIZE, check_presence, cookie, + t2_cookie_release); + + /* Specific Mifare check presence */ + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K: + case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K: + return mifare_check_presence(adapter_idx, target_idx, + cb, tgt_subtype); + + default: + DBG("Unknown TAG Type 2 subtype %d", tgt_subtype); + + return -1; + } +} + +static int format_resp(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t2_cookie *cookie = data; + struct near_tag *tag; + + DBG(""); + + if (length < 0 || resp[0] != 0) { + err = -EIO; + goto out_err; + } + + tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + DBG("Done formatting"); + near_tag_set_blank(tag, FALSE); + +out_err: + return t2_cookie_release(err, cookie); +} + +static int nfctype2_format(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb) +{ + struct type2_cmd cmd; + struct t2_cookie *cookie; + struct near_ndef_message *cc_ndef; + struct type2_cc *t2_cc; + struct near_tag *tag; + enum near_tag_sub_type tgt_subtype; + int err; + + DBG(""); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + return -EINVAL; + + + tgt_subtype = near_tag_get_subtype(adapter_idx, target_idx); + + if (tgt_subtype != NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT) { + DBG("Unknown Tag Type 2 subtype %d", tgt_subtype); + return -1; + } + + t2_cc = g_try_malloc0(sizeof(struct type2_cc)); + cc_ndef = g_try_malloc0(sizeof(struct near_ndef_message)); + cookie = g_try_malloc0(sizeof(struct t2_cookie)); + + if (!t2_cc || !cc_ndef || !cookie) { + err = -ENOMEM; + goto out_err; + } + + t2_cc->magic = TYPE2_MAGIC; + t2_cc->version = TYPE2_TAG_VER_1_0; + t2_cc->mem_size = TYPE2_DATA_SIZE_48; + t2_cc->read_write = TYPE2_READWRITE_ACCESS; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->current_block = CC_BLOCK_START; + cookie->ndef = cc_ndef; + cookie->ndef->data = (uint8_t *) t2_cc; + cookie->cb = cb; + + cmd.cmd = CMD_WRITE; + cmd.block = CC_BLOCK_START; + memcpy(cmd.data, (uint8_t *) t2_cc, BLOCK_SIZE); + + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + sizeof(cmd), format_resp, cookie, NULL); + +out_err: + if (err < 0) { + g_free(t2_cc); + g_free(cc_ndef); + g_free(cookie); + } + + return err; +} + +static struct near_tag_driver type2_driver = { + .type = NFC_PROTO_MIFARE, + .priority = NEAR_TAG_PRIORITY_DEFAULT, + .read = nfctype2_read, + .write = nfctype2_write, + .check_presence = nfctype2_check_presence, + .format = nfctype2_format, +}; + +static int nfctype2_init(void) +{ + DBG(""); + + return near_tag_driver_register(&type2_driver); +} + +static void nfctype2_exit(void) +{ + DBG(""); + + near_tag_driver_unregister(&type2_driver); +} + +NEAR_PLUGIN_DEFINE(nfctype2, "NFC Forum Type 2 tags support", VERSION, + NEAR_PLUGIN_PRIORITY_HIGH, nfctype2_init, nfctype2_exit)
diff --git a/neard/plugins/nfctype3.c b/neard/plugins/nfctype3.c new file mode 100644 index 0000000..7b026b0 --- /dev/null +++ b/neard/plugins/nfctype3.c
@@ -0,0 +1,998 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/tag.h> +#include <near/ndef.h> +#include <near/tlv.h> + +#define CMD_POLL 0x00 +#define RESP_POLL 0x01 + +#define CMD_REQUEST_SERVICE 0x02 +#define RESP_REQUEST_SERVICE 0x03 + +#define CMD_REQUEST_RESPONSE 0x04 +#define RESP_REQUEST_RESPONSE 0x05 + +#define CMD_READ_WO_ENCRYPT 0x06 +#define RESP_READ_WO_ENCRYPT 0x07 + +#define CMD_WRITE_WO_ENCRYPT 0x08 +#define RESP_WRITE_WO_ENCRYPT 0x09 + +#define CMD_REQUEST_SYS_CODE 0x0C +#define RESP_REQUEST_SYS_CODE 0x0D + +#define CMD_AUTHENTICATION_1 0x10 +#define RESP_AUTHENTICATION_1 0x11 + +#define CMD_AUTHENTICATION_2 0x12 +#define RESP_AUTHENTICATION_2 0x13 + +#define CMD_READ 0x14 +#define RESP_READ 0x15 + +#define CMD_WRITE 0x16 +#define RESP_WRITE 0x17 + +#define NFC_SERVICE_CODE 0x000B +#define BLOCK_SIZE 16 +#define META_BLOCK_START 0 +#define DATA_BLOCK_START 1 + +#define LEN_ID 0x08 +#define LEN_CMD 0x01 +#define LEN_REPLY_CMD 0x02 +#define LEN_CMD_LEN 0x01 + +/* offsets */ +#define OFS_NFC_STATUS 0 +#define OFS_NFC_LEN 1 +#define OFS_CMD_RESP 2 +#define OFS_IDM 3 +#define OFS_CMD_DATA (LEN_CMD_LEN + LEN_CMD + LEN_ID) +#define OFS_READ_FLAG 12 +#define OFS_READ_DATA 14 +#define BLOCK_SIZE 16 +#define CHECKSUM_LEN 2 + +#define MAX_DATA_SIZE 254 + +#define NDEF_MAPPING_VERSION 0x10 +#define MAX_READ_BLOCKS_PER_CHECK 0x04 +#define MAX_WRITE_BLOCKS_PER_UPDATE 0x01 +#define MAX_BLOCKS_FOR_NDEF_DATA 0x000D +#define ATTR_BLOCK_WRITE_FLAG 0x00 +#define ATTR_BLOCK_RW_FLAG 0x01 + +#define IC_TYPE_OFFSET 12 +#define SYSTEM_OPTION_OFFSET 17 +#define FELICA_LITE_MC_BLOCK 0x88 +#define FELICA_LITE_IC_TYPE 0xF0 +#define FELICA_LITE_S_IC_TYPE 0xF1 +#define FELICA_PLUG_IC_TYPE 0xE0 + +#define FELICA_LITE_AND_LITE_S_SYS_CODE 0x88B4 + +struct type3_cmd { + uint8_t len; + uint8_t cmd; + uint8_t data[MAX_DATA_SIZE]; +} __attribute__((packed)); + +struct type3_tag { + uint32_t adapter_idx; + uint16_t current_block; + uint8_t IDm[LEN_ID]; + + near_tag_io_cb cb; + struct near_tag *tag; +}; + +struct t3_cookie { + uint32_t adapter_idx; + uint32_t target_idx; + near_tag_io_cb cb; + uint8_t IDm[LEN_ID]; + uint8_t current_block; + uint8_t attr[BLOCK_SIZE]; + struct near_ndef_message *ndef; + uint8_t ic_type; + uint8_t mc_block[BLOCK_SIZE]; +}; + +static int t3_cookie_release(int err, void *data) +{ + struct t3_cookie *cookie = data; + + DBG("%p", cookie); + + if (!cookie) + return err; + + if (cookie->cb) + cookie->cb(cookie->adapter_idx, cookie->target_idx, err); + + if (cookie->ndef) + g_free(cookie->ndef->data); + + g_free(cookie->ndef); + g_free(cookie); + cookie = NULL; + + return err; +} + +/* common: Initialize structure to write block */ +static void prepare_write_block(uint8_t *UID, struct type3_cmd *cmd, + uint8_t block, uint8_t *data) +{ + cmd->cmd = CMD_WRITE_WO_ENCRYPT; /* command */ + memcpy(cmd->data, UID, LEN_ID); /* IDm */ + + cmd->data[LEN_ID] = 1; /* number of services */ + cmd->data[LEN_ID + 1] = 0x09; /* service 0x0009 */ + cmd->data[LEN_ID + 2] = 0x00; + + cmd->data[LEN_ID + 3] = 0x01; /* number of blocks */ + cmd->data[LEN_ID + 4] = 0x80; /* 2 byte block number format */ + cmd->data[LEN_ID + 5] = block; /* block number */ + memcpy(cmd->data + LEN_ID + 6, data, BLOCK_SIZE); /* data to write */ + + cmd->len = LEN_ID + LEN_CMD + LEN_CMD_LEN + 6 + BLOCK_SIZE; +} + +/* common: Initialize structure to read block */ +static void prepare_read_block(uint8_t cur_block, + uint8_t *UID, + struct type3_cmd *cmd) +{ + cmd->cmd = CMD_READ_WO_ENCRYPT; /* command */ + memcpy(cmd->data, UID, LEN_ID); /* IDm */ + + cmd->data[LEN_ID] = 1; /* number of service */ + cmd->data[LEN_ID + 1] = 0x0B; /* service x000B */ + cmd->data[LEN_ID + 2] = 0x00; + + cmd->data[LEN_ID + 3] = 0x01; /* number of block */ + cmd->data[LEN_ID + 4] = 0x80; /* 2 bytes block id*/ + cmd->data[LEN_ID + 5] = cur_block; /* block number */ + + cmd->len = LEN_ID + LEN_CMD + LEN_CMD_LEN + 6; +} + +/* common: Simple checks on received frame */ +static int check_recv_frame(uint8_t *resp, uint8_t reply_code) +{ + if (resp[OFS_NFC_STATUS] != 0) { + DBG("NFC Command failed: 0x%x", resp[OFS_NFC_STATUS]); + return -EIO; + } + + if (resp[OFS_CMD_RESP] != reply_code) { + DBG("Felica cmd failed: 0x%x", resp[OFS_CMD_RESP]); + return -EIO; + } + + return 0; +} + +static int data_recv(uint8_t *resp, int length, void *data) +{ + struct type3_tag *tag = data; + struct type3_cmd cmd; + uint8_t *nfc_data; + size_t current_length, length_read, data_length; + uint32_t adapter_idx; + uint32_t target_idx; + int read_blocks; + int err; + + DBG("%d", length); + + adapter_idx = near_tag_get_adapter_idx(tag->tag); + target_idx = near_tag_get_target_idx(tag->tag); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + nfc_data = near_tag_get_data(tag->tag, &data_length); + length_read = length - OFS_READ_DATA; + current_length = tag->current_block * BLOCK_SIZE; + if (current_length + (length - OFS_READ_DATA) > data_length) + length_read = data_length - current_length; + + memcpy(nfc_data + current_length, resp + OFS_READ_DATA, length_read); + + if (current_length + length_read >= data_length) { + GList *records; + + tag->current_block = 0; + + DBG("Done reading %zd bytes at %p", data_length, nfc_data); + records = near_ndef_parse_msg(nfc_data, data_length, NULL); + near_tag_add_records(tag->tag, records, tag->cb, 0); + + g_free(tag); + + return 0; + } + + /* Read the next block */ + read_blocks = length / BLOCK_SIZE; + tag->current_block += read_blocks; + + prepare_read_block(DATA_BLOCK_START + tag->current_block, + tag->IDm, &cmd); + + err = near_adapter_send(adapter_idx, (uint8_t *) &cmd, cmd.len, + data_recv, tag, NULL); + + if (err < 0) + goto out_err; + + return 0; + +out_err: + if (err < 0 && tag->cb) + tag->cb(adapter_idx, target_idx, err); + + g_free(tag); + + return err; +} + +static int data_read(struct type3_tag *tag) +{ + struct type3_cmd cmd; + uint32_t adapter_idx; + + DBG(""); + + tag->current_block = 0; + + prepare_read_block(DATA_BLOCK_START + tag->current_block, + tag->IDm, &cmd); + + adapter_idx = near_tag_get_adapter_idx(tag->tag); + + return near_adapter_send(adapter_idx, + (uint8_t *) &cmd, cmd.len, + data_recv, tag, NULL); +} + +/* Read block 0 to retrieve the data length */ +static int nfctype3_recv_block_0(uint8_t *resp, int length, void *data) +{ + struct t3_cookie *cookie = data; + int err = 0; + struct near_tag *tag; + struct type3_tag *t3_tag = NULL; + uint32_t ndef_data_length; + + DBG("%d", length); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + err = check_recv_frame(resp, RESP_READ_WO_ENCRYPT); + if (err < 0) + goto out_err; + + if (resp[OFS_READ_FLAG] != 0) { + DBG("Status 0x%x", resp[OFS_READ_FLAG]); + err = -EIO; + goto out_err; + } + + /* Block 0:[11 - 13]: length is a 3 bytes value */ + ndef_data_length = resp[OFS_READ_DATA + 11] * 0x100; + ndef_data_length += resp[OFS_READ_DATA + 12]; + ndef_data_length *= 0x100; + ndef_data_length += resp[OFS_READ_DATA + 13]; + + /* Add data to the tag */ + err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx, + NULL, ndef_data_length); + if (err < 0) + goto out_err; + + tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx); + if (!tag) { + err = -ENOMEM; + goto out_err; + } + + /* Block 0:[10]: RW Flag. 1 for RW */ + if (resp[OFS_READ_DATA + 10] == 0) + near_tag_set_ro(tag, TRUE); + else + near_tag_set_ro(tag, FALSE); + + t3_tag = g_try_malloc0(sizeof(struct type3_tag)); + if (!t3_tag) { + err = -ENOMEM; + goto out_err; + } + + memcpy(t3_tag->IDm, cookie->IDm, LEN_ID); + + near_tag_set_idm(tag, cookie->IDm, LEN_ID); + near_tag_set_attr_block(tag, resp + OFS_READ_DATA, BLOCK_SIZE); + near_tag_set_blank(tag, FALSE); + near_tag_set_ic_type(tag, cookie->ic_type); + + t3_tag->adapter_idx = cookie->adapter_idx; + t3_tag->cb = cookie->cb; + t3_tag->tag = tag; + + err = data_read(t3_tag); + + /* + * As reading isn't complete, + * callback shouldn't be called while freeing the cookie + */ + if (err >= 0) + cookie->cb = NULL; + +out_err: + if (err < 0) + g_free(t3_tag); + + return t3_cookie_release(err, cookie); +} + +static int poll_ndef_system_code(uint8_t *resp, int length, void *data) +{ + struct t3_cookie *cookie = data; + int err = 0; + struct type3_cmd cmd; + + DBG("length: %d", length); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + err = check_recv_frame(resp, RESP_POLL); + if (err < 0) + goto out_err; + + prepare_read_block(META_BLOCK_START, cookie->IDm, &cmd); + + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + cmd.len, nfctype3_recv_block_0, cookie, NULL); + if (err < 0) + goto out_err; + + return 0; + +out_err: + return t3_cookie_release(err, cookie); +} + +static int check_sys_op_in_mc_block(uint8_t *resp, int length, void *data) +{ + struct type3_cmd cmd; + struct near_tag *tag; + struct t3_cookie *cookie = data; + int err = 0; + + DBG("length %d", length); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + err = check_recv_frame(resp, RESP_READ_WO_ENCRYPT); + if (err < 0) + goto out_err; + + if (resp[SYSTEM_OPTION_OFFSET] == 0x00) { + DBG("Blank tag detected"); + + err = near_tag_add_data(cookie->adapter_idx, + cookie->target_idx, + NULL, 1 /* dummy length */); + if (err < 0) + goto out_err; + + tag = near_tag_get_tag(cookie->adapter_idx, + cookie->target_idx); + if (!tag) { + err = -ENOMEM; + goto out_err; + } + + near_tag_set_idm(tag, cookie->IDm, LEN_ID); + near_tag_set_ic_type(tag, cookie->ic_type); + near_tag_set_blank(tag, TRUE); + + return t3_cookie_release(0, cookie); + } else { + /* CMD POLL */ + cmd.cmd = CMD_POLL; /* POLL command */ + cmd.data[0] = 0x12; /* System code (NFC SC) */ + cmd.data[1] = 0xFC; + cmd.data[2] = 01; /* request code */ + cmd.data[3] = 0x00; /* time slot */ + /* data len + 2 bytes */ + cmd.len = LEN_CMD + LEN_CMD_LEN + 4 ; + + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + cmd.len , poll_ndef_system_code, cookie, NULL); + } + + if (err < 0) + goto out_err; + + return 0; + +out_err: + return t3_cookie_release(err, cookie); +} + +static int receive_system_code(uint8_t *resp, int length, void *data) +{ + struct t3_cookie *cookie = data; + int err = 0; + struct type3_cmd cmd; + + DBG("length: %d", length); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + err = check_recv_frame(resp, RESP_POLL); + if (err < 0) + goto out_err; + + cookie->ic_type = resp[IC_TYPE_OFFSET]; + memcpy(cookie->IDm, resp + OFS_IDM, LEN_ID); + + switch (resp[IC_TYPE_OFFSET]) { + case FELICA_LITE_IC_TYPE: + prepare_read_block(FELICA_LITE_MC_BLOCK, cookie->IDm, &cmd); + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + cmd.len, check_sys_op_in_mc_block, + cookie, NULL); + break; + + default: + /* CMD POLL */ + cmd.cmd = CMD_POLL; /* POLL command */ + cmd.data[0] = 0x12; /* System code (NFC SC) */ + cmd.data[1] = 0xFC; + cmd.data[2] = 01; /* request code */ + cmd.data[3] = 0x00; /* time slot */ + /* data len + 2 bytes */ + cmd.len = LEN_CMD + LEN_CMD_LEN + 4 ; + + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + cmd.len, poll_ndef_system_code, cookie, + NULL); + } + + if (err < 0) + goto out_err; + + return 0; + +out_err: + return t3_cookie_release(err, cookie); +} + +static int nfctype3_read(uint32_t adapter_idx, + uint32_t target_idx, near_tag_io_cb cb) +{ + struct type3_cmd cmd; + struct t3_cookie *cookie; + + DBG(""); + + /* CMD POLL */ + cmd.cmd = CMD_POLL; /* POLL command */ + cmd.data[0] = 0xFF; /* System code */ + cmd.data[1] = 0xFF; + cmd.data[2] = 01; /* request code */ + cmd.data[3] = 0x00; /* time slot */ + + /* data len + 2 bytes */ + cmd.len = LEN_CMD + LEN_CMD_LEN + 4; + + cookie = g_try_malloc0(sizeof(struct t3_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + return near_adapter_send(adapter_idx, (uint8_t *) &cmd, cmd.len, + receive_system_code, cookie, + t3_cookie_release); +} + +static int update_attr_block_cb(uint8_t *resp, int length, void *data) +{ + struct t3_cookie *cookie = data; + int err; + + DBG(""); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + err = check_recv_frame(resp, RESP_WRITE_WO_ENCRYPT); + if (err < 0) + goto out_err; + + DBG("Done writing"); + +out_err: + return t3_cookie_release(err, cookie); +} + +static int update_attr_block(struct t3_cookie *cookie) +{ + struct type3_cmd cmd; + uint16_t checksum; + uint8_t i; + + DBG(""); + + cookie->attr[9] = 0x00; /* writing data completed */ + cookie->attr[11] = (uint8_t) (cookie->ndef->length >> 16); + cookie->attr[12] = (uint8_t) (cookie->ndef->length >> 8); + cookie->attr[13] = (uint8_t) cookie->ndef->length; + checksum = 0; + + for (i = 0; i < (BLOCK_SIZE - CHECKSUM_LEN); i++) + checksum += cookie->attr[i]; + + cookie->attr[14] = (uint8_t) (checksum >> 8); + cookie->attr[15] = (uint8_t) checksum; + + prepare_write_block(cookie->IDm, &cmd, 0, cookie->attr); + + return near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, + update_attr_block_cb, cookie, + t3_cookie_release); +} + +static int data_write_resp(uint8_t *resp, int length, void *data) +{ + struct t3_cookie *cookie = data; + struct type3_cmd cmd; + uint8_t padding[BLOCK_SIZE] = {0}; + int err; + + DBG(""); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + err = check_recv_frame(resp, RESP_WRITE_WO_ENCRYPT); + if (err < 0) + goto out_err; + + if (cookie->ndef->offset >= cookie->ndef->length) { + err = update_attr_block(cookie); + if (err < 0) + goto out_err; + + return 0; + } + + if ((cookie->ndef->length - cookie->ndef->offset) < + BLOCK_SIZE) { + memcpy(padding, cookie->ndef->data + cookie->ndef->offset, + cookie->ndef->length - cookie->ndef->offset); + prepare_write_block(cookie->IDm, &cmd, + cookie->current_block, padding); + } else { + prepare_write_block(cookie->IDm, &cmd, cookie->current_block, + cookie->ndef->data + cookie->ndef->offset); + } + + cookie->current_block++; + cookie->ndef->offset += BLOCK_SIZE; + + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, + data_write_resp, cookie, NULL); + if (err < 0) + goto out_err; + + return 0; + +out_err: + return t3_cookie_release(err, cookie); +} + +static int data_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + struct near_tag *tag, + near_tag_io_cb cb) +{ + struct t3_cookie *cookie; + struct type3_cmd cmd; + uint16_t checksum, nmaxb; + uint8_t i, len = 0; + uint8_t *idm, *attr; + int err; + + DBG(""); + + cookie = g_try_malloc0(sizeof(struct t3_cookie)); + + if (!cookie) { + err = -ENOMEM; + + if (cb) + cb(adapter_idx, target_idx, err); + + return err; + } + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->ndef = ndef; + cookie->cb = cb; + cookie->current_block = 0; + + idm = near_tag_get_idm(tag, &len); + if (!idm) + return t3_cookie_release(-EINVAL, cookie); + + memcpy(cookie->IDm, idm, len); + + attr = near_tag_get_attr_block(tag, &len); + if (!attr) + return t3_cookie_release(-EINVAL, cookie); + + memcpy(cookie->attr, attr, len); + nmaxb = (((uint16_t) (cookie->attr[3])) << 8) | cookie->attr[4]; + + if (cookie->ndef->length > (nmaxb * BLOCK_SIZE)) { + near_error("not enough space on tag"); + + return t3_cookie_release(-ENOSPC, cookie); + } + + cookie->attr[9] = 0x0F; /* writing data in progress */ + checksum = 0; + + for (i = 0; i < 14; i++) + checksum += cookie->attr[i]; + + cookie->attr[14] = (uint8_t) (checksum >> 8); + cookie->attr[15] = (uint8_t) checksum; + + prepare_write_block(cookie->IDm, &cmd, cookie->current_block, + cookie->attr); + cookie->current_block++; + + return near_adapter_send(adapter_idx, (uint8_t *) &cmd, cmd.len, + data_write_resp, cookie, + t3_cookie_release); +} + +static int nfctype3_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_tag_io_cb cb) +{ + struct near_tag *tag; + int err; + + DBG(""); + + if (!ndef || !cb) { + err = -EINVAL; + goto out_err; + } + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + err = data_write(adapter_idx, target_idx, ndef, tag, cb); + +out_err: + return err; +} + +static int check_presence(uint8_t *resp, int length, void *data) +{ + struct t3_cookie *cookie = data; + int err = 0; + + DBG("length %d", length); + + if (length < 0) { + err = -EIO; + goto out; + } + + if (cookie->cb) + cookie->cb(cookie->adapter_idx, cookie->target_idx, err); + +out: + return t3_cookie_release(err, cookie); +} + +static int nfctype3_check_presence(uint32_t adapter_idx, + uint32_t target_idx, near_tag_io_cb cb) +{ + struct type3_cmd cmd; + struct t3_cookie *cookie; + + DBG(""); + + /* CMD POLL */ + cmd.cmd = CMD_POLL; /* POLL command */ + cmd.data[0] = 0xFF; /* System code */ + cmd.data[1] = 0xFF; + cmd.data[2] = 01; /* request code */ + cmd.data[3] = 0x00; /* time slot */ + + /* data len + 2 bytes */ + cmd.len = LEN_CMD + LEN_CMD_LEN + 4 ; + + cookie = g_try_malloc0(sizeof(struct t3_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + return near_adapter_send(adapter_idx, (uint8_t *) &cmd, + cmd.len, check_presence, cookie, + t3_cookie_release); +} + +static int format_resp(uint8_t *resp, int length, void *data) +{ + struct near_tag *tag; + struct t3_cookie *cookie = data; + int err; + + DBG(""); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + err = check_recv_frame(resp, RESP_WRITE_WO_ENCRYPT); + if (err < 0) + goto out_err; + + tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx); + if (!tag) { + err = -ENOMEM; + goto out_err; + } + + near_tag_set_ro(tag, FALSE); + near_tag_set_idm(tag, cookie->IDm, LEN_ID); + near_tag_set_attr_block(tag, cookie->attr, BLOCK_SIZE); + near_tag_set_blank(tag, FALSE); + + DBG("Formatting is done"); + +out_err: + return t3_cookie_release(err, cookie); +} + +static int write_attr_block(uint8_t *resp, int length , void *data) +{ + struct type3_cmd cmd; + struct t3_cookie *cookie = data; + int err, i; + uint16_t checksum = 0; + + DBG("length %d", length); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + err = check_recv_frame(resp, RESP_WRITE_WO_ENCRYPT); + if (err < 0) + goto out_err; + + cookie->attr[0] = NDEF_MAPPING_VERSION; + cookie->attr[1] = MAX_READ_BLOCKS_PER_CHECK; + cookie->attr[2] = MAX_WRITE_BLOCKS_PER_UPDATE; + cookie->attr[3] = (uint8_t) (MAX_BLOCKS_FOR_NDEF_DATA >> 8); + cookie->attr[4] = (uint8_t) (MAX_BLOCKS_FOR_NDEF_DATA); + cookie->attr[5] = 0; + cookie->attr[6] = 0; + cookie->attr[7] = 0; + cookie->attr[8] = 0; + cookie->attr[9] = ATTR_BLOCK_WRITE_FLAG; + cookie->attr[10] = ATTR_BLOCK_RW_FLAG; + cookie->attr[11] = 0; + cookie->attr[12] = 0; + cookie->attr[13] = 0; + + for (i = 0; i < (BLOCK_SIZE - CHECKSUM_LEN); i++) + checksum += cookie->attr[i]; + + cookie->attr[14] = (uint8_t) (checksum >> 8); + cookie->attr[15] = (uint8_t) checksum; + + prepare_write_block(cookie->IDm, &cmd, META_BLOCK_START, + cookie->attr); + + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + cmd.len, format_resp, cookie, NULL); + if (err < 0) + goto out_err; + + return 0; + +out_err: + return t3_cookie_release(err, cookie); +} + +static int write_mc_block(uint8_t *resp, int length, void *data) +{ + struct type3_cmd cmd; + struct t3_cookie *cookie = data; + int err; + + DBG("length %d", length); + + if (length < 0) { + err = -EIO; + goto out_err; + } + + err = check_recv_frame(resp, RESP_READ_WO_ENCRYPT); + if (err < 0) + goto out_err; + + if (resp[OFS_READ_FLAG] != 0) { + DBG("Status 0x%x", resp[OFS_READ_FLAG]); + err = -EIO; + goto out_err; + } + + memcpy(cookie->mc_block, resp + 14, BLOCK_SIZE); + /* + * By updating Byte3 to 01h means making Felica Lite + * compatible with NDEF. + */ + cookie->mc_block[3] = 1; + prepare_write_block(cookie->IDm, &cmd, FELICA_LITE_MC_BLOCK, + cookie->mc_block); + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, + cmd.len, write_attr_block, cookie, NULL); + if (err < 0) + goto out_err; + + return 0; + +out_err: + return t3_cookie_release(err, cookie); +} + +static int nfctype3_format(uint32_t adapter_idx, + uint32_t target_idx, near_tag_io_cb cb) +{ + struct type3_cmd cmd; + struct near_tag *tag; + struct t3_cookie *cookie; + uint8_t ic_type; + uint8_t *idm, len; + + DBG(""); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + return -ENOMEM; + + ic_type = near_tag_get_ic_type(tag); + if (ic_type != FELICA_LITE_IC_TYPE) + return -EOPNOTSUPP; + + cookie = g_try_malloc0(sizeof(struct t3_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + cookie->ic_type = ic_type; + + idm = near_tag_get_idm(tag, &len); + if (!idm) + return t3_cookie_release(-EINVAL, cookie); + + memcpy(cookie->IDm, idm, len); + + prepare_read_block(FELICA_LITE_MC_BLOCK, cookie->IDm, &cmd); + + return near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, + write_mc_block, cookie, + t3_cookie_release); + +} + +static struct near_tag_driver type1_driver = { + .type = NFC_PROTO_FELICA, + .priority = NEAR_TAG_PRIORITY_DEFAULT, + .read = nfctype3_read, + .write = nfctype3_write, + .format = nfctype3_format, + .check_presence = nfctype3_check_presence, +}; + +static int nfctype3_init(void) +{ + DBG(""); + + return near_tag_driver_register(&type1_driver); +} + +static void nfctype3_exit(void) +{ + DBG(""); + + near_tag_driver_unregister(&type1_driver); +} + +NEAR_PLUGIN_DEFINE(nfctype3, "NFC Forum Type 3 tags support", VERSION, + NEAR_PLUGIN_PRIORITY_HIGH, nfctype3_init, nfctype3_exit)
diff --git a/neard/plugins/nfctype4.c b/neard/plugins/nfctype4.c new file mode 100644 index 0000000..6f2e6e6 --- /dev/null +++ b/neard/plugins/nfctype4.c
@@ -0,0 +1,1487 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/tag.h> +#include <near/ndef.h> +#include <near/tlv.h> + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +#define NFC_STATUS 0 +#define NFC_STATUS_BYTE_LEN 1 + +#define STATUS_WORD_1 1 +#define STATUS_WORD_2 2 +#define APDU_HEADER_LEN 5 +#define APDU_OK 0x9000 +#define APDU_NOT_FOUND 0x6A82 + +/* PICC Level Commands */ +#define PICC_CLASS 0x90 +#define GET_VERSION 0x60 +#define CREATE_APPLICATION 0xCA +#define SELECT_APPLICATION 0x5A +#define CREATE_STD_DATA_FILE 0xCD +#define WRITE_DATA_TO_FILE 0x3D + +#define DESFire_EV1_MAJOR_VERSION 0x01 +#define PICC_LEVEL_APDU_OK 0x9100 +#define GET_VERSION_FRAME_RESPONSE_BYTE 0xAF +#define DESFIRE_KEY_SETTINGS 0x0F +#define DESFIRE_NUM_OF_KEYS 0x21 +#define DESFIRE_CC_FILE_NUM 0x01 +#define DESFIRE_NDEF_FILE_NUM 0x02 +#define DESFIRE_COMMSET 0x00 +#define MAPPING_VERSION 0x20 +#define FREE_READ_ACCESS 0x00 +#define FREE_WRITE_ACCESS 0x00 + +#define T4_ALL_ACCESS 0x00 +#define T4_READ_ONLY 0xFF + +#define APDU_STATUS(a) near_get_be16(a) + +/* Tag Type 4 version ID */ +static uint8_t iso_appname_v1[] = { 0xd2, 0x76, 0x0, 0x0, 0x85, 0x01, 0x0 }; +static uint8_t iso_appname_v2[] = { 0xd2, 0x76, 0x0, 0x0, 0x85, 0x01, 0x1 }; + +/* Tag T4 File ID */ +static uint8_t iso_cc_fileid[] = { 0xe1, 0x03 }; +#define LEN_ISO_CC_FILEID 2 + +#define LEN_ISO_CC_READ_SIZE 0x0F + +#define CMD_HEADER_SIZE 5 +struct type4_cmd { /* iso 7816 */ + uint8_t class; + uint8_t instruction; + uint8_t param1; + uint8_t param2; + uint8_t data_length; + uint8_t data[]; +} __attribute__((packed)); + +struct type4_NDEF_file_control_tlv { + uint8_t tag ; /* should be 4 */ + uint8_t len ; /* should be 6 */ + uint16_t file_id ; + uint16_t max_ndef_size ; + uint8_t read_access ; + uint8_t write_access ; +} __attribute__((packed)); + +struct type4_cc { /* Capability Container */ + uint16_t CCLEN; + uint8_t mapping_version; + uint16_t max_R_apdu_data_size; + uint16_t max_C_apdu_data_size; + struct type4_NDEF_file_control_tlv tlv_fc ; + uint8_t tlv_blocks[]; +} __attribute__((packed)); + +struct desfire_app { + uint8_t aid[3]; + uint8_t key_settings; + uint8_t number_of_keys; + uint8_t file_id[2]; + uint8_t iso_appname[7]; +} __attribute__((packed)); + +struct desfire_std_file { + uint8_t file_num; + uint8_t file_id[2]; + uint8_t comm_set; + uint8_t access_rights[2]; + uint8_t size[3]; +} __attribute__((packed)); + +struct desfire_cc_file { + uint8_t file_num; + uint8_t offset[3]; + uint8_t max_len[3]; + uint8_t cc_len[2]; + uint8_t version; + uint8_t mle[2]; + uint8_t mlc[2]; + uint8_t ndef_tlv[4]; + uint8_t ndef_size[2]; + uint8_t read_access; + uint8_t write_access; +} __attribute__((packed)); + +struct t4_cookie { + uint32_t adapter_idx; + uint32_t target_idx; + near_tag_io_cb cb; + struct near_tag *tag; + uint16_t read_data; + uint16_t r_apdu_max_size; + uint16_t c_apdu_max_size; + uint16_t max_ndef_size; + uint8_t write_access; + struct near_ndef_message *ndef; + uint16_t memory_size; +}; + +static int t4_cookie_release(int err, void *data) +{ + struct t4_cookie *cookie = data; + + DBG("%p", cookie); + + if (!cookie) + return err; + + if (err < 0 && cookie->cb) + cookie->cb(cookie->adapter_idx, cookie->target_idx, err); + + if (cookie->ndef) + g_free(cookie->ndef->data); + + g_free(cookie->ndef); + g_free(cookie); + + return err; +} + +/* ISO functions: This code prepares APDU */ +static int ISO_send_cmd(uint8_t class, + uint8_t instruction, + uint8_t param1, + uint8_t param2, + uint8_t *cmd_data, + uint8_t cmd_data_length, + bool le, + near_recv cb, + void *in_data) +{ + struct type4_cmd *cmd; + struct t4_cookie *in_rcv = in_data; + uint8_t total_cmd_length; + int err; + + DBG("CLA-%02x INS-%02x P1-%02x P2-%02x", + class, instruction, param1, param2); + + if (!le) { + if (cmd_data) + total_cmd_length = APDU_HEADER_LEN + cmd_data_length; + else + total_cmd_length = APDU_HEADER_LEN; + } else { /* Extra byte for Le */ + total_cmd_length = APDU_HEADER_LEN + cmd_data_length + 1; + } + + cmd = g_try_malloc0(total_cmd_length); + if (!cmd) { + DBG("Mem alloc failed"); + err = t4_cookie_release(-ENOMEM, in_rcv); + goto out_err; + } + + cmd->class = class; + cmd->instruction = instruction ; + cmd->param1 = param1 ; + cmd->param2 = param2 ; + cmd->data_length = cmd_data_length; + + if (cmd_data) { + memcpy(cmd->data, cmd_data, cmd_data_length); + /* The Le byte set to 0x00 defined that any length + * of PICC response is allowed */ + if (le) + cmd->data[cmd_data_length] = 0; + } + + err = near_adapter_send(in_rcv->adapter_idx, (uint8_t *) cmd, + total_cmd_length, cb, in_rcv, + t4_cookie_release); + +out_err: + /* On exit, clean memory */ + g_free(cmd); + + return err; +} + +/* ISO 7816 command: Select applications or files + * p1=0 select by "file id" + * P1=4 select by "DF name" + * If P1 == 0, then P2 is 0x0C. + * If P2 == 4, then P2 is 0x00. + * */ +static int ISO_Select(uint8_t *filename, uint8_t fnamelen, uint8_t P1, + near_recv cb, void *cookie) +{ + uint16_t P2; + + DBG(""); + + P2 = P1 ? 0x00 : 0x0C; + + return ISO_send_cmd( + 0x00, /* CLA */ + 0xA4, /* INS: Select file */ + P1, /* P1: select by name */ + P2, /* P2: First or only occurrence */ + filename, /* cmd_data */ + fnamelen, /* uint8_t cmd_data_length*/ + false, + cb, + cookie); +} + +/* ISO 7816 command: Read binary data from files */ +static int ISO_ReadBinary(uint16_t offset, uint8_t readsize, + near_recv cb, void *cookie) +{ + DBG(""); + return ISO_send_cmd( + 0x00, /* CLA */ + 0xB0, /* INS: Select file */ + (uint8_t) ((offset & 0xFF00) >> 8), + (uint8_t) (offset & 0xFF), + 0, /* no data send */ + readsize, /* bytes to read */ + false, + cb, + cookie); +} + +/* ISO 7816 command: Update data */ +static int ISO_Update(uint16_t offset, uint8_t nlen, + uint8_t *data, near_recv cb, void *cookie) +{ + DBG(""); + return ISO_send_cmd( + 0x00, /* CLA */ + 0xD6, /* INS: Select file */ + (uint8_t) ((offset & 0xFF00) >> 8), + (uint8_t) (offset & 0xFF), + data, /* length of NDEF data */ + nlen, /* NLEN + NDEF data */ + false, + cb, + cookie); +} + +static int data_read_cb(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data ; + uint8_t *nfc_data; + size_t data_length, length_read, current_length; + uint16_t remain_bytes; + + DBG("%d", length); + + if (length < 0) + return t4_cookie_release(length, cookie); + + if (APDU_STATUS(resp + length - 2) != APDU_OK) { + DBG("Fail read_cb SW:x%04x", APDU_STATUS(resp + length - 2)); + + return t4_cookie_release(-EIO, cookie); + } + + nfc_data = near_tag_get_data(cookie->tag, &data_length); + + /* Remove SW1 / SW2 and NFC header */ + length_read = length - NFC_HEADER_SIZE - 2 ; + length = length_read; + + current_length = cookie->read_data; + + if ((current_length + length_read) > data_length) + length_read = data_length - current_length; + + memcpy(nfc_data + current_length, resp + NFC_HEADER_SIZE, length_read); + if ((current_length + length_read) == data_length) { + GList *records; + + DBG("Done reading"); + + records = near_ndef_parse_msg(nfc_data, data_length, NULL); + near_tag_add_records(cookie->tag, records, cookie->cb, 0); + + return t4_cookie_release(0, cookie); + } + + cookie->read_data += length ; + remain_bytes = data_length - cookie->read_data; + + if (remain_bytes >= cookie->r_apdu_max_size) + return ISO_ReadBinary(cookie->read_data + 2, + cookie->r_apdu_max_size, data_read_cb, cookie); + else + return ISO_ReadBinary(cookie->read_data + 2, + (uint8_t) remain_bytes, data_read_cb, cookie); +} + +static int t4_readbin_NDEF_ID(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data; + struct near_tag *tag = cookie->tag; + size_t data_length; + int err; + + DBG("%d", length); + + if (length < 0) + return t4_cookie_release(length, cookie); + + if (APDU_STATUS(resp + length - 2) != APDU_OK) { + DBG("Fail SW:x%04x", APDU_STATUS(resp + length - 2)); + + return t4_cookie_release(-EIO, cookie); + } + + data_length = near_get_be16(resp + NFC_STATUS_BYTE_LEN); + + /* Add data to the tag */ + err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx, NULL, + data_length); + if (err < 0) + return t4_cookie_release(err, cookie); + + near_tag_set_blank(tag, FALSE); + + /* Set write conditions */ + if (cookie->write_access == T4_READ_ONLY) + near_tag_set_ro(tag, TRUE); + else + near_tag_set_ro(tag, FALSE); + + /* + * TODO: see how we can get the UID value: + * near_tag_set_uid(tag, resp + NFC_HEADER_SIZE, 8); + */ + + /* Read 1st block */ + if (data_length >= cookie->r_apdu_max_size) + return ISO_ReadBinary(2, cookie->r_apdu_max_size, data_read_cb, + cookie); + else + return ISO_ReadBinary(2, (uint8_t) data_length, data_read_cb, + cookie); +} + +static int t4_get_file_len(struct t4_cookie *cookie) +{ + cookie->r_apdu_max_size = near_tag_get_r_apdu_max_size(cookie->tag); + + /* Read 2 bytes from offset 0 which conatins the NDEF file length */ + return ISO_ReadBinary(0, 2, t4_readbin_NDEF_ID, cookie); +} + +static int t4_select_NDEF_ID(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data; + + DBG("%d", length); + + if (length < 0) + return t4_cookie_release(length, cookie); + + /* Check for APDU error */ + if (APDU_STATUS(resp + STATUS_WORD_1) != APDU_OK) { + DBG("Fail SW:x%04x", APDU_STATUS(resp + STATUS_WORD_1)); + + return t4_cookie_release(-EIO, cookie); + } + + return t4_get_file_len(cookie); +} + +static int t4_readbin_cc(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data; + struct type4_cc *read_cc = (struct type4_cc *)&resp[1]; + + DBG("%d", length); + + if (length < 0) + return t4_cookie_release(length, cookie); + + /* Check APDU error ( the two last bytes of the resp) */ + if (APDU_STATUS(resp + length - 2) != APDU_OK) { + DBG("Fail SW:x%04x", APDU_STATUS(resp + length - 2)); + + return t4_cookie_release(-EIO, cookie); + } + + cookie->r_apdu_max_size = g_ntohs(read_cc->max_R_apdu_data_size) - + APDU_HEADER_LEN; + cookie->c_apdu_max_size = g_ntohs(read_cc->max_C_apdu_data_size); + cookie->max_ndef_size = g_ntohs(read_cc->tlv_fc.max_ndef_size); + + near_tag_set_max_ndef_size(cookie->tag, cookie->max_ndef_size); + near_tag_set_c_apdu_max_size(cookie->tag, cookie->c_apdu_max_size); + near_tag_set_r_apdu_max_size(cookie->tag, cookie->r_apdu_max_size); + + /* TODO 5.1.1: TLV blocks can be zero, one or more... */ + /* TODO 5.1.2: Must ignore proprietary blocks (x05)... */ + if (read_cc->tlv_fc.tag != 0x4) { + DBG("NDEF File Control tag not found"); + + return t4_cookie_release(-EINVAL, cookie); + } + + /* save rw conditions */ + cookie->write_access = read_cc->tlv_fc.write_access; + + near_tag_set_file_id(cookie->tag, read_cc->tlv_fc.file_id); + + return ISO_Select((uint8_t *) &read_cc->tlv_fc.file_id, + LEN_ISO_CC_FILEID, 0, t4_select_NDEF_ID, cookie); +} + +static int t4_select_cc(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data; + int err; + + DBG("%d", length); + + if (length < 0) + return t4_cookie_release(length, cookie); + + /* Check for APDU error */ + if (APDU_STATUS(resp + STATUS_WORD_1) != APDU_OK) { + + DBG(" Found empty tag"); + /* Add data to the tag */ + err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx, + NULL, 1 /* dummy length */); + if (err < 0) + return t4_cookie_release(err, cookie); + + near_tag_set_blank(cookie->tag, TRUE); + + if (cookie->cb) + cookie->cb(cookie->adapter_idx, cookie->target_idx, 0); + + return t4_cookie_release(0, cookie); + } + + return ISO_ReadBinary(0, LEN_ISO_CC_READ_SIZE, t4_readbin_cc, cookie); +} + +static int t4_select_file_by_name_v1(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data; + + DBG("%d", length); + + if (length < 0) + return t4_cookie_release(length, cookie); + + /* Check for APDU error */ + if (APDU_STATUS(resp + STATUS_WORD_1) != APDU_OK) { + DBG("V1 Fail SW:x%04x", APDU_STATUS(resp + STATUS_WORD_1)); + + return t4_cookie_release(-EIO, cookie); + } + + if (resp[NFC_STATUS] != 0) + return t4_cookie_release(-EIO, cookie); + + /* Jump to select phase */ + return ISO_Select(iso_cc_fileid, LEN_ISO_CC_FILEID, 0, + t4_select_cc, cookie); +} + +static int t4_select_file_by_name_v2(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data; + + DBG("%d", length); + + if (length < 0) + return t4_cookie_release(length, cookie); + + /* Check for APDU error - Not found */ + if (APDU_STATUS(resp + STATUS_WORD_1) == APDU_NOT_FOUND) { + DBG("Fallback to V1"); + + return ISO_Select(iso_appname_v1, ARRAY_SIZE(iso_appname_v1), + 0x4, t4_select_file_by_name_v1, cookie); + } + + if (APDU_STATUS(resp + STATUS_WORD_1) != APDU_OK) { + DBG("V2 Fail SW:x%04x", APDU_STATUS(resp + STATUS_WORD_1)); + + return t4_cookie_release(-EIO, cookie); + } + + if (resp[NFC_STATUS] != 0) + return t4_cookie_release(-EIO, cookie); + + /* Jump to select phase */ + return ISO_Select(iso_cc_fileid, LEN_ISO_CC_FILEID, 0, t4_select_cc, + cookie); +} + +static int nfctype4_read(uint32_t adapter_idx, + uint32_t target_idx, near_tag_io_cb cb) +{ + struct t4_cookie *cookie; + + DBG(""); + + cookie = g_try_malloc0(sizeof(struct t4_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->tag = near_tag_get_tag(adapter_idx, target_idx); + if (!cookie->tag) + return t4_cookie_release(-ENOMEM, cookie); + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + cookie->read_data = 0; + + /* + * If the NDEF file has already been selected by a previous + * read, check_presence, or format operation, go straight + * to reading the NDEF file length. Otherwise, go through the + * complete NDEF detection procedure. If near_tag_get_r_apdu_max_size() + * returns anything other than 0, we know the NDEF file is selected. + */ + if (near_tag_get_r_apdu_max_size(cookie->tag)) + return t4_get_file_len(cookie); + else + return ISO_Select(iso_appname_v2, ARRAY_SIZE(iso_appname_v2), + 0x4, t4_select_file_by_name_v2, cookie); +} + +static int data_write_cb(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data; + int err = 0; + + DBG("%d", length); + + if (length < 0) + return t4_cookie_release(length, cookie); + + if (APDU_STATUS(resp + length - 2) != APDU_OK) { + near_error("write failed SWx%04x", + APDU_STATUS(resp + length - 2)); + + return t4_cookie_release(-EIO, cookie); + } + + if (cookie->ndef->offset >= cookie->ndef->length) { + DBG("Done writing"); + + if (cookie->cb) + cookie->cb(cookie->adapter_idx, cookie->target_idx, 0); + + return t4_cookie_release(0, cookie); + } + + if ((cookie->ndef->length - cookie->ndef->offset) > + cookie->c_apdu_max_size) { + err = ISO_Update(cookie->ndef->offset, + cookie->c_apdu_max_size, + cookie->ndef->data + cookie->ndef->offset, + data_write_cb, cookie); + cookie->ndef->offset += cookie->c_apdu_max_size; + } else { + err = ISO_Update(cookie->ndef->offset, + cookie->ndef->length - cookie->ndef->offset, + cookie->ndef->data + cookie->ndef->offset, + data_write_cb, cookie); + cookie->ndef->offset = cookie->ndef->length; + } + + return err; +} + +static int data_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + struct near_tag *tag, near_tag_io_cb cb) +{ + struct t4_cookie *cookie; + int err; + + cookie = g_try_malloc0(sizeof(struct t4_cookie)); + + if (!cookie) { + err = -ENOMEM; + + if (cb) + cb(adapter_idx, target_idx, err); + + return err; + } + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + cookie->tag = NULL; + cookie->read_data = 0; + cookie->max_ndef_size = near_tag_get_max_ndef_size(tag); + cookie->c_apdu_max_size = near_tag_get_c_apdu_max_size(tag); + cookie->ndef = ndef; + + if (cookie->max_ndef_size < cookie->ndef->length) { + near_error("not enough space on tag to write data"); + err = -ENOSPC; + goto out_err; + } + + if ((cookie->ndef->length - cookie->ndef->offset) > + cookie->c_apdu_max_size) { + err = ISO_Update(cookie->ndef->offset, + cookie->c_apdu_max_size, + cookie->ndef->data, + data_write_cb, cookie); + cookie->ndef->offset += cookie->c_apdu_max_size; + } else { + err = ISO_Update(cookie->ndef->offset, + cookie->ndef->length, + cookie->ndef->data, + data_write_cb, cookie); + cookie->ndef->offset = cookie->ndef->length; + } + + return err; + +out_err: + if (cb) + cb(adapter_idx, target_idx, err); + + return err; +} + +static int nfctype4_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, near_tag_io_cb cb) +{ + struct near_tag *tag; + int err; + + DBG(""); + + if (!ndef || !cb) { + err = -EINVAL; + goto out_err; + } + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + return data_write(adapter_idx, target_idx, ndef, tag, cb); + +out_err: + if (cb) + cb(adapter_idx, target_idx, err); + + return err; +} + +static int check_presence(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data; + int err = 0; + + DBG("%d", length); + + if (length < 0) + err = -EIO; + + if (cookie->cb) + cookie->cb(cookie->adapter_idx, + cookie->target_idx, err); + + return t4_cookie_release(err, cookie); +} + +static int nfctype4_check_presence(uint32_t adapter_idx, + uint32_t target_idx, near_tag_io_cb cb) +{ + struct t4_cookie *cookie; + struct near_tag *tag; + uint16_t file_id; + + DBG(""); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + return -EINVAL; + + cookie = g_try_malloc0(sizeof(struct t4_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + cookie->tag = NULL; + cookie->read_data = 0; + + file_id = near_tag_get_file_id(tag); + + /* Check for V2 type 4 tag */ + return ISO_Select((uint8_t *)&file_id, LEN_ISO_CC_FILEID, 0, + check_presence, cookie); +} + +static int select_ndef_file(uint8_t *resp, int length, void *data) +{ + struct near_tag *tag; + struct t4_cookie *cookie = data; + + DBG("%d", length); + + if (length < 0) + return t4_cookie_release(length, cookie); + + if (APDU_STATUS(resp + STATUS_WORD_1) != APDU_OK) { + near_error("select ndef file resp failed %02X", + resp[length - 1]); + + tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx); + if (tag) { + near_tag_set_max_ndef_size(tag, 0); + near_tag_set_c_apdu_max_size(tag, 0); + near_tag_set_r_apdu_max_size(tag, 0); + } + + return t4_cookie_release(-EIO, cookie); + } + + DBG("ndef file selected"); + + if (cookie->cb) + cookie->cb(cookie->adapter_idx, cookie->target_idx, 0); + + return t4_cookie_release(0, cookie); +} + +static int read_cc_file(uint8_t *resp, int length, void *data) +{ + struct t4_cookie *cookie = data; + struct near_tag *tag; + struct type4_cc *read_cc = NULL; + int err = 0; + + DBG("%d", length); + + if (length < 0) { + err = length; + goto out_err; + } + + /* Check APDU error ( the two last bytes of the resp) */ + if (APDU_STATUS(resp + length - 2) != APDU_OK) { + near_error("read cc failed SWx%04x", + APDU_STATUS(resp + length - 2)); + err = -EIO; + goto out_err; + } + + /* -2 for status word and -1 is for NFC first byte... */ + read_cc = g_try_malloc0(length - 2 - NFC_STATUS_BYTE_LEN); + if (!read_cc) { + err = -ENOMEM; + goto out_err; + } + + memcpy(read_cc, &resp[1], length - 2 - NFC_STATUS_BYTE_LEN) ; + cookie->r_apdu_max_size = g_ntohs(read_cc->max_R_apdu_data_size) - + APDU_HEADER_LEN; + cookie->c_apdu_max_size = g_ntohs(read_cc->max_C_apdu_data_size); + cookie->max_ndef_size = g_ntohs(read_cc->tlv_fc.max_ndef_size); + + tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + near_tag_set_max_ndef_size(tag, cookie->memory_size); + near_tag_set_c_apdu_max_size(tag, cookie->c_apdu_max_size); + near_tag_set_r_apdu_max_size(tag, cookie->r_apdu_max_size); + + if (read_cc->tlv_fc.tag != 0x4) { + near_error("NDEF File not found") ; + err = -EINVAL ; + goto out_err; + } + + err = ISO_Select((uint8_t *)&read_cc->tlv_fc.file_id, + LEN_ISO_CC_FILEID, 0, select_ndef_file, cookie); + if (err < 0) + near_error("select ndef file req failed %d", err); + + g_free(read_cc); + return err; + +out_err: + g_free(read_cc); + return t4_cookie_release(err, cookie); +} + +static int select_cc_file(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t4_cookie *cookie = data; + + if (length < 0) { + near_error("CC file select resp failed %d", length); + + return t4_cookie_release(length, cookie); + } + + if (APDU_STATUS(resp + STATUS_WORD_1) != APDU_OK) { + near_error("CC file select response %02X", + resp[length - 1]); + + return t4_cookie_release(-EIO, cookie); + } + + err = ISO_ReadBinary(0, LEN_ISO_CC_READ_SIZE, read_cc_file, cookie); + if (err < 0) + near_error("read cc file req failed %d", err); + + return err; +} + +static int select_iso_appname_v2(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t4_cookie *cookie = data; + + if (length < 0) { + near_error("iso app select resp failed %d", length); + + return t4_cookie_release(length, cookie); + } + + if (resp[NFC_STATUS] != 0x00) { + near_error("iso app select response %02X", + resp[length - 1]); + + return t4_cookie_release(-EIO, cookie); + } + + err = ISO_Select(iso_cc_fileid, LEN_ISO_CC_FILEID, 0, + select_cc_file, cookie); + if (err < 0) + near_error("select cc req failed %d", err); + + return err; +} + +static int format_resp(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t4_cookie *cookie = data; + struct near_tag *tag; + + DBG(""); + + if (length < 0) { + near_error("write data to ndef file resp failed %d", length); + + return t4_cookie_release(length, cookie); + } + + if (APDU_STATUS(resp + 1) != PICC_LEVEL_APDU_OK) { + near_error("wrtie data to ndef file response %02X", + resp[length - 1]); + + return t4_cookie_release(-EIO, cookie); + } + + tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx); + if (!tag) + return t4_cookie_release(-EINVAL, cookie); + + DBG("Formatting is done"); + near_tag_set_blank(tag, FALSE); + + /* + * 1) Till now all commands which are used for formatting are + * at mifare desfire level. Now select iso appname_v2, + * cc file and ndef file with ISO 7816-4 commands. + * 2) Selecting ndef file means making sure that read write + * operations will perform on NDEF file. + */ + err = ISO_Select(iso_appname_v2, ARRAY_SIZE(iso_appname_v2), + 0x4, select_iso_appname_v2, cookie); + if (err < 0) + near_error("iso_select appnamev2 req failed %d", err); + + return err; +} + +static int write_data_to_ndef_file(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t4_cookie *cookie = data; + uint8_t *cmd_data = NULL; + uint8_t cmd_data_length; + uint8_t ndef_file_offset[] = {0x00, 0x00, 0x00}; + uint8_t empty_ndef_file_len[] = {0x02, 0x00, 0x00}; /* 000002h */ + uint8_t ndef_nlen[] = {0x00, 0x00}; /* 0000h */ + + DBG(""); + + if (length < 0) { + near_error("create ndef file resp failed %d", length); + err = length; + goto out_err; + } + + if (APDU_STATUS(resp + 1) != PICC_LEVEL_APDU_OK) { + near_error("create ndef file response %02X", + resp[length - 1]); + err = -EIO; + goto out_err; + } + + /* Step8 : Write data to NDEF file ( no NDEF message) */ + cmd_data_length = 1 /* File num */ + + ARRAY_SIZE(ndef_file_offset) + + ARRAY_SIZE(empty_ndef_file_len) + + ARRAY_SIZE(ndef_nlen); + + cmd_data = g_try_malloc0(cmd_data_length); + if (!cmd_data) { + err = -ENOMEM; + goto out_err; + } + + cmd_data[0] = DESFIRE_NDEF_FILE_NUM; + memcpy(cmd_data + 1, ndef_file_offset, ARRAY_SIZE(ndef_file_offset)); + memcpy(cmd_data + 4, empty_ndef_file_len, + ARRAY_SIZE(empty_ndef_file_len)); + memcpy(cmd_data + 7, ndef_nlen, ARRAY_SIZE(ndef_nlen)); + + err = ISO_send_cmd(PICC_CLASS, WRITE_DATA_TO_FILE, + 0x00, 0x00, cmd_data, cmd_data_length, + true, format_resp, cookie); + if (err < 0) + near_error("wrtie data to ndef file req failed %d", err); + + g_free(cmd_data); + return err; + +out_err: + g_free(cmd_data); + return t4_cookie_release(err, cookie); +} + +static int create_ndef_file(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t4_cookie *cookie = data; + struct desfire_std_file *ndef = NULL; + uint8_t iso_ndef_file_id[] = {0x04, 0xE1}; /* E104h */ + uint8_t ndef_file_access_rights[] = {0xE0, 0xEE}; /* EEE0h */ + + DBG(""); + + if (length < 0) { + near_error("write data to cc file resp failed %d", length); + err = length; + goto out_err; + } + + if (APDU_STATUS(resp + 1) != PICC_LEVEL_APDU_OK) { + near_error("write data to cc file response %02X", + resp[length - 1]); + err = -EIO; + goto out_err; + } + + ndef = g_try_malloc0(sizeof(struct desfire_std_file)); + if (!ndef) { + err = -ENOMEM; + goto out_err; + } + + ndef->file_num = DESFIRE_NDEF_FILE_NUM; + memcpy(ndef->file_id, iso_ndef_file_id, ARRAY_SIZE(iso_ndef_file_id)); + ndef->comm_set = DESFIRE_COMMSET; + memcpy(ndef->access_rights, ndef_file_access_rights, + ARRAY_SIZE(ndef_file_access_rights)); + ndef->size[0] = 0; + ndef->size[1] = (uint8_t) (cookie->memory_size >> 8); + ndef->size[2] = (uint8_t) cookie->memory_size; + + err = ISO_send_cmd(PICC_CLASS, CREATE_STD_DATA_FILE, + 0x00, 0x00, (uint8_t *)ndef, + sizeof(struct desfire_std_file), + true, write_data_to_ndef_file, cookie); + if (err < 0) + near_error("create ndef file req failed %d", err); + + g_free(ndef); + return err; + +out_err: + g_free(ndef); + return t4_cookie_release(err, cookie); +} + +static int write_data_to_cc_file(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t4_cookie *cookie = data; + struct desfire_cc_file *cc = NULL; + uint8_t cc_file_offset[] = {0x00, 0x00, 0x00}; + uint8_t cc_file_max_len[] = {0x0F, 0x00, 0x00}; /* 00000Fh */ + uint8_t cc_len[] = {0x00, 0x0F}; /* 000Fh*/ + uint8_t mle_r_apdu[] = {0x00, 0x3B}; /* 003Bh */ + uint8_t mlc_c_apdu[] = {0x00, 0x34}; /* 0034h */ + /* T: 04, L: 06: V: E104h (NDEF ISO FID = E104h)*/ + uint8_t ndef_tlv[] = {0x04, 0x06, 0xE1, 0x04}; + + + DBG(""); + + if (length < 0) { + near_error("create cc file resp failed %d", length); + err = length; + goto out_err; + } + + if (APDU_STATUS(resp + 1) != PICC_LEVEL_APDU_OK) { + near_error("create cc file response %02X", + resp[length - 1]); + err = -EIO; + goto out_err; + } + + cc = g_try_malloc0(sizeof(struct desfire_cc_file)); + if (!cc) { + err = -ENOMEM; + goto out_err; + } + + cc->file_num = DESFIRE_CC_FILE_NUM; + memcpy(cc->offset, cc_file_offset, ARRAY_SIZE(cc_file_offset)); + memcpy(cc->max_len, cc_file_max_len, ARRAY_SIZE(cc_file_max_len)); + memcpy(cc->cc_len, cc_len, ARRAY_SIZE(cc_len)); + cc->version = MAPPING_VERSION; + memcpy(cc->mle, mle_r_apdu, ARRAY_SIZE(mle_r_apdu)); + memcpy(cc->mlc, mlc_c_apdu, ARRAY_SIZE(mlc_c_apdu)); + memcpy(cc->ndef_tlv, ndef_tlv, ARRAY_SIZE(ndef_tlv)); + cc->ndef_size[0] = (uint8_t) (cookie->memory_size >> 8); + cc->ndef_size[1] = (uint8_t) cookie->memory_size; + cc->read_access = FREE_READ_ACCESS; + cc->write_access = FREE_WRITE_ACCESS; + + err = ISO_send_cmd(PICC_CLASS, WRITE_DATA_TO_FILE, + 0x00, 0x00, (uint8_t *)cc, + sizeof(struct desfire_cc_file), + true, create_ndef_file, cookie); + if (err < 0) + near_error("write data to cc file req failed %d", err); + + g_free(cc); + return err; + +out_err: + g_free(cc); + return t4_cookie_release(err, cookie); +} + +static int create_cc_file(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t4_cookie *cookie = data; + struct desfire_std_file *cc = NULL; + uint8_t iso_cc_file_id[] = {0x03, 0xe1}; /* E103h */ + uint8_t cc_file_access_rights[] = {0xE0, 0xEE}; /* EEE0h */ + uint8_t cc_file_max_len[] = {0x0F, 0x00, 0x00}; /* 00000Fh */ + + DBG(""); + + if (length < 0) { + near_error("select application1 resp failed %d", length); + err = length; + goto out_err; + } + + if (APDU_STATUS(resp + 1) != PICC_LEVEL_APDU_OK) { + near_error("select application1 response %02X", + resp[length - 1]); + err = -EIO; + goto out_err; + } + + cc = g_try_malloc0(sizeof(struct desfire_std_file)); + if (!cc) { + err = -ENOMEM; + goto out_err; + } + + cc->file_num = DESFIRE_CC_FILE_NUM; + memcpy(cc->file_id, iso_cc_file_id, ARRAY_SIZE(iso_cc_file_id)); + cc->comm_set = DESFIRE_COMMSET; + memcpy(cc->access_rights, cc_file_access_rights, + ARRAY_SIZE(cc_file_access_rights)); + memcpy(cc->size, cc_file_max_len, ARRAY_SIZE(cc_file_max_len)); + + err = ISO_send_cmd(PICC_CLASS, + CREATE_STD_DATA_FILE, + 0x00, 0x00, (uint8_t *)cc, + sizeof(struct desfire_std_file), + true, write_data_to_cc_file, cookie); + if (err < 0) + near_error("create cc file req failed %d", err); + + g_free(cc); + return err; + +out_err: + g_free(cc); + return t4_cookie_release(err, cookie); +} + +static int select_application_1(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t4_cookie *cookie = data; + uint8_t *cmd_data = NULL; + uint8_t cmd_data_length; + uint8_t desfire_aid_1[] = {0x01, 0x00, 0x00}; /* 000001h */ + + DBG(""); + + if (length < 0) { + near_error("create application resp failed %d", length); + err = length; + goto out_err; + } + + if (APDU_STATUS(resp + 1) != PICC_LEVEL_APDU_OK) { + near_error("create application response %02X", + resp[length - 1]); + err = -EIO; + goto out_err; + } + + /* Step4 : Select application (which is created just now) */ + cmd_data_length = ARRAY_SIZE(desfire_aid_1); + cmd_data = g_try_malloc0(cmd_data_length); + if (!cmd_data) { + err = -ENOMEM; + goto out_err; + } + + memcpy(cmd_data, desfire_aid_1, cmd_data_length); + err = ISO_send_cmd(PICC_CLASS, SELECT_APPLICATION, + 0x00, 0x00, cmd_data, cmd_data_length, + true, create_cc_file, cookie); + if (err < 0) + near_error("select application1 req failed %d", err); + + g_free(cmd_data); + return err; + +out_err: + g_free(cmd_data); + return t4_cookie_release(err, cookie); +} + +static int create_application(uint8_t *resp, int length, void *data) +{ + int err = 0; + struct t4_cookie *cookie = data; + uint8_t desfire_aid_1[] = {0x01, 0x00, 0x00}; /* 000001h */ + uint8_t desfire_file_id[] = {0x10, 0xE1}; /* E110h */ + struct desfire_app *app = NULL; + + DBG(""); + + if (length < 0) { + near_error("select application resp failed %d", length); + err = length; + goto out_err; + } + + if (APDU_STATUS(resp + 1) != PICC_LEVEL_APDU_OK) { + near_error("select application response %02X", + resp[length - 1]); + err = -EIO; + goto out_err; + } + + app = g_try_malloc0(sizeof(struct desfire_app)); + if (!app) { + err = -ENOMEM; + goto out_err; + } + + memcpy(app->aid, desfire_aid_1, ARRAY_SIZE(desfire_aid_1)); + app->key_settings = DESFIRE_KEY_SETTINGS; + app->number_of_keys = DESFIRE_NUM_OF_KEYS; + memcpy(app->file_id, desfire_file_id, ARRAY_SIZE(desfire_file_id)); + memcpy(app->iso_appname, iso_appname_v2, ARRAY_SIZE(iso_appname_v2)); + + /* Step3 : Create Application */ + err = ISO_send_cmd(PICC_CLASS, CREATE_APPLICATION, + 0x00, 0x00, (uint8_t *)app, + sizeof(struct desfire_app), + true, select_application_1, cookie); + if (err < 0) + near_error("create application req failed %d", err); + + g_free(app); + return err; + +out_err: + g_free(app); + return t4_cookie_release(err, cookie); +} + +static int select_application(uint8_t *resp, int length, void *data) +{ + int err; + struct t4_cookie *cookie = data; + uint8_t *cmd_data = NULL; + uint8_t cmd_data_length; + uint8_t desfire_aid[] = {0x00, 0x00, 0x00}; /* 000000h */ + + DBG(""); + + if (length < 0) { + near_error("get version3 resp failed %d", length); + err = length; + goto out_err; + } + + if (resp[length - 1] != 0x00) { + near_error("get version3 response %02X", + resp[length - 1]); + err = -EIO; + goto out_err; + } + + /* AID : 000000h */ + cmd_data_length = ARRAY_SIZE(desfire_aid); + cmd_data = g_try_malloc0(cmd_data_length); + if (!cmd_data) { + err = -ENOMEM; + goto out_err; + } + + memcpy(cmd_data, desfire_aid, cmd_data_length); + /* Step2 : Select Application */ + err = ISO_send_cmd(PICC_CLASS, + SELECT_APPLICATION, + 0x00, 0x00, cmd_data, cmd_data_length, + true, create_application, cookie); + if (err < 0) + near_error("select application req failed %d", err); + + g_free(cmd_data); + return err; + +out_err: + g_free(cmd_data); + return t4_cookie_release(err, cookie); +} + +static int get_version_frame3(uint8_t *resp, int length, void *data) +{ + int err; + struct t4_cookie *cookie = data; + + DBG(""); + + if (length < 0) { + near_error("get version2 resp failed %d", length); + + return t4_cookie_release(length, cookie); + } + + if (resp[4] == 0x01 /* Major Version */ + && resp[length - 1] == GET_VERSION_FRAME_RESPONSE_BYTE) { + + err = ISO_send_cmd(PICC_CLASS, + GET_VERSION_FRAME_RESPONSE_BYTE, + 0x00, 0x00, NULL, 0, false, + select_application, cookie); + if (err < 0) + near_error("get version3 req failed %d", err); + + return err; + } + + near_error("get version2 response %02X", resp[length - 1]); + + return t4_cookie_release(-EIO, cookie); +} + +static int get_version_frame2(uint8_t *resp, int length, void *data) +{ + int err; + struct t4_cookie *cookie = data; + + DBG(""); + + if (length < 0) { + near_error(" get version resp failed %d", length); + + return t4_cookie_release(length, cookie); + } + + if (resp[4] == 0x01 /* Major Version */ + && resp[length - 1] == GET_VERSION_FRAME_RESPONSE_BYTE) { + + /* + * When N is the GET_VERSION response 6th byte, + * the DESFire tag memory size is 2 ^ (N /2). + */ + cookie->memory_size = (1 << (resp[6] / 2)); + err = ISO_send_cmd(PICC_CLASS, + GET_VERSION_FRAME_RESPONSE_BYTE, + 0x00, 0x00, NULL, 0, false, + get_version_frame3, cookie); + if (err < 0) + near_error("get version2 req failed %d", err); + + return err; + } + + near_error("get version response %02X", resp[length - 1]); + + return t4_cookie_release(-EIO, cookie); +} + +/* Steps to format Type 4 (MIFARE DESFire EV1) tag as per AN1104.pdf from nxp. + * 1) Get version to determine memory size of tag + * 2) Select applciation with AID equal to 000000h (PICC level) + * 3) Create application with AID equal to 000001h + * 4) Select application (Select previously created application in step3) + * 5) Create std data file with File number equal to 01h (CC file), ISOFileID + * equal to E103h, ComSet equal to 00h, AccesRights to EEEEh, FileSize bigger + * equal to 00000Fh + * 6) Write data to CC file with CCLEN equal to 000Fh, Mapping version equal to + * 20h, MLe equal to 003Bh, MLc equal to 0034h, and NDEF File control TLV + * equal to: T=04h, L=06h, V=E1 04 (NDEF ISO FID = E104h), 08 00 (NDEF File + * size = 2048 Bytes) 00 (free read access) 00 (free write access) + * 7) Create std data file with File number equal to 02h (NDEF File DESFireFId), + * ISO FileID equal to E104h, ComSet equal to 00h, ComSet equal to 00h, + * AccessRights equal to EEE0h, FileSize equal to 000800h (2048 bytes) + * 8) Write data to write content of the NDEF File with NLEN equal to 0000h, and + * no NDEF messsage. + * 9) Now Formatting is done, then select ISO appname2, select CC file and read. + * 10) Select NDEF file (by doing last two steps means, making sure that read + * write operations perform on NDEF file). + * */ + +static int nfctype4_format(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb) +{ + int err; + struct t4_cookie *cookie; + + DBG(""); + + cookie = g_try_malloc0(sizeof(struct t4_cookie)); + if (!cookie) + return -ENOMEM; + + cookie->adapter_idx = adapter_idx; + cookie->target_idx = target_idx; + cookie->cb = cb; + + /* Step1 : Get Version */ + err = ISO_send_cmd(PICC_CLASS, GET_VERSION, + 0x00, 0x00, NULL, 0, false, + get_version_frame2, cookie); + + if (err < 0) + near_error("get version req failed %d", err); + + return err; +} + +static struct near_tag_driver type4a_driver = { + .type = NFC_PROTO_ISO14443, + .priority = NEAR_TAG_PRIORITY_DEFAULT, + .read = nfctype4_read, + .write = nfctype4_write, + .check_presence = nfctype4_check_presence, + .format = nfctype4_format, +}; + +static struct near_tag_driver type4b_driver = { + .type = NFC_PROTO_ISO14443_B, + .priority = NEAR_TAG_PRIORITY_DEFAULT, + .read = nfctype4_read, + .write = nfctype4_write, + .check_presence = nfctype4_check_presence, + .format = nfctype4_format, +}; + +static int nfctype4_init(void) +{ + int ret; + + DBG(""); + + ret = near_tag_driver_register(&type4b_driver); + if (ret < 0) + return ret; + + return near_tag_driver_register(&type4a_driver); +} + +static void nfctype4_exit(void) +{ + DBG(""); + + near_tag_driver_unregister(&type4a_driver); + near_tag_driver_unregister(&type4b_driver); +} + +NEAR_PLUGIN_DEFINE(nfctype4, "NFC Forum Type 4 tags support", VERSION, + NEAR_PLUGIN_PRIORITY_HIGH, nfctype4_init, nfctype4_exit)
diff --git a/neard/plugins/nfctype5.c b/neard/plugins/nfctype5.c new file mode 100644 index 0000000..3c21ab7 --- /dev/null +++ b/neard/plugins/nfctype5.c
@@ -0,0 +1,1080 @@ +/* + * NFC Type 5 (ISO 15693) Tag code + * + * Copyright (C) 2013 Animal Creek Technologies, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +/* + * Currently only single block reads and writes are used for I/O. + * The read multiple command is used but only to determine if the + * tag supports it which is necessary when setting the CC info + * during format. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/tag.h> +#include <near/ndef.h> +#include <near/tlv.h> + +/* Only Type 5 NDEF version 1.0 is supported */ +#define TYPE5_VERSION_MAJOR 1 +#define TYPE5_VERSION_MINOR 0 + +/* + * Type 5 NDEF CC Byte 2 can only indicate memory sizes up to 2040 bytes + * (0xff * 8). Any memory beyond that will be unused (ISO/15693 cards + * can have up to 8192 bytes of memory)--this may chnge once the Type 5 + * spec is finialized. + */ +#define TYPE5_MAX_MEM_SIZE 2040 + +/* + * At one point the NFC-V specification committee was supposed to + * have agreed that that the NDEF data area will start at the + * beginning of the first *block* after the end of the CC data + * (which is 4 bytes long) regardless of the tag's block size. + * It turns out that this may not be the case but until things + * are finalized assume that is the case. + * + * For Example: + * - If the tag's block size is 1 byte, the data area starts at + * the beginning of 5th block (offset 4). + * - If the tag's block size is 32 bytes, the data area starts at + * the beginning of the 2nd block (offset 32). + */ +#define TYPE5_META_START_OFFSET 0 + +#define TYPE5_DATA_START_OFFSET(t) \ + MAX(near_tag_get_blk_size(t), sizeof(struct type5_cc)) + +#define TYPE5_LEN_CC_BYTES 0x04 + +#define TYPE5_CC0_NDEF_MAGIC 0xe1 + +#define TYPE5_CC1_VER_MAJOR_SHIFT 6 +#define TYPE5_CC1_VER_MINOR_SHIFT 4 +#define TYPE5_CC1_READ_ACCESS_SHIFT 2 +#define TYPE5_CC1_WRITE_ACCESS_SHIFT 0 + +#define TYPE5_CC1_VER_MAJOR_MASK (0x3 << TYPE5_CC1_VER_MAJOR_SHIFT) +#define TYPE5_CC1_VER_MINOR_MASK (0x3 << TYPE5_CC1_VER_MINOR_SHIFT) +#define TYPE5_CC1_READ_ACCESS_MASK (0x3 << TYPE5_CC1_READ_ACCESS_SHIFT) +#define TYPE5_CC1_WRITE_ACCESS_MASK (0x3 << TYPE5_CC1_WRITE_ACCESS_SHIFT) + +#define TYPE5_CC1_VER_GET_MAJOR(v) (((v) & TYPE5_CC1_VER_MAJOR_MASK) >> \ + TYPE5_CC1_VER_MAJOR_SHIFT) +#define TYPE5_CC1_VER_GET_MINOR(v) (((v) & TYPE5_CC1_VER_MINOR_MASK) >> \ + TYPE5_CC1_VER_MINOR_SHIFT) + +#define TYPE5_CC1_READ_ACCESS_ALWAYS (0x0 << TYPE5_CC1_READ_ACCESS_SHIFT) +#define TYPE5_CC1_WRITE_ACCESS_ALWAYS (0x0 << TYPE5_CC1_WRITE_ACCESS_SHIFT) +#define TYPE5_CC1_WRITE_ACCESS_PROPRIETARY (0x2 << TYPE5_CC1_WRITE_ACCESS_SHIFT) +#define TYPE5_CC1_WRITE_ACCESS_NEVER (0x3 << TYPE5_CC1_WRITE_ACCESS_SHIFT) +#define TYPE5_CC1_WRITE_ACCESS_NEVER (0x3 << TYPE5_CC1_WRITE_ACCESS_SHIFT) + +#define TYPE5_CC3_MBREAD_FLAG 0x01 +#define TYPE5_CC3_LOCK_FLAG 0x08 +#define TYPE5_CC3_SPECIAL_FRAME_FLAG 0x10 + +#define CMD_FLAG_SUB_CARRIER 0x01 +#define CMD_FLAG_DATA_RATE 0x02 +#define CMD_FLAG_INVENTORY 0x04 +#define CMD_FLAG_PROTOCOL_EXT 0x08 +#define CMD_FLAG_SELECT 0x10 +#define CMD_FLAG_ADDRESS 0x20 +#define CMD_FLAG_OPTION 0x40 + +#define RESP_FLAG_ERR 0x01 +#define RESP_FLAG_EXT 0x08 + +#define CMD_READ_SINGLE_BLOCK 0x20 +#define CMD_WRITE_SINGLE_BLOCK 0x21 +#define CMD_READ_MULITPLE_BLOCKS 0x23 +#define CMD_GET_SYSTEM_INFO 0x2b + +#define GET_SYS_INFO_FLAG_DSFID 0x01 +#define GET_SYS_INFO_FLAG_AFI 0x02 +#define GET_SYS_INFO_FLAG_MEM_SIZE 0x04 +#define GET_SYS_INFO_FLAG_IC_REF 0x08 +#define GET_SYS_INFO_FLAG_16B_NB_BLOCK 0x10 + +struct type5_cmd_hdr { + uint8_t flags; + uint8_t cmd; + uint8_t uid[NFC_MAX_ISO15693_UID_LEN]; +} __attribute__((packed)); + +struct type5_err_resp { + uint8_t flags; + uint8_t err_code; +} __attribute__((packed)); + +struct type5_read_single_block_cmd { + struct type5_cmd_hdr hdr; + uint8_t blk_no; +} __attribute__((packed)); + +struct type5_read_single_block_resp { + uint8_t flags; + uint8_t data[0]; +} __attribute__((packed)); + +struct type5_write_single_block_cmd { + struct type5_cmd_hdr hdr; + uint8_t blk_no; + uint8_t data[0]; +} __attribute__((packed)); + +struct type5_write_single_block_resp { + uint8_t flags; +} __attribute__((packed)); + +struct type5_read_multiple_blocks_cmd { + struct type5_cmd_hdr hdr; + uint8_t blk_no; + uint8_t num_blks; +} __attribute__((packed)); + +struct type5_read_multiple_blocks_resp { + uint8_t flags; + uint8_t data[0]; +} __attribute__((packed)); + +struct type5_get_system_info_cmd { + struct type5_cmd_hdr hdr; +} __attribute__((packed)); + +struct type5_get_system_info_resp { + uint8_t flags; + uint8_t info_flags; + uint8_t uid[NFC_MAX_ISO15693_UID_LEN]; + uint8_t data[0]; +} __attribute__((packed)); + +struct type5_cc { + uint8_t cc0; + uint8_t cc1; + uint8_t cc2; + uint8_t cc3; +} __attribute__((packed)); + +typedef int (*t5_local_cb)(struct near_tag *tag, int err, void *data); + +struct t5_cookie { + struct near_tag *tag; + near_tag_io_cb cb; + t5_local_cb local_cb; + uint8_t *local_cb_data; + uint8_t *buf; + struct near_ndef_message *ndef; + int src_offset; + int dst_offset; + size_t bytes_left; + uint8_t blk; + uint8_t nb_requested_blocks; +}; + +static int t5_cmd_hdr_init(struct near_tag *tag, struct type5_cmd_hdr *cmd_hdr, + int cmd) +{ + uint8_t *uid; + + DBG(""); + + uid = near_tag_get_iso15693_uid(near_tag_get_adapter_idx(tag), + near_tag_get_target_idx(tag)); + if (!uid) { + near_error("No type 5 UID"); + return -EINVAL; + } + + cmd_hdr->flags = CMD_FLAG_ADDRESS | CMD_FLAG_DATA_RATE; + cmd_hdr->cmd = cmd; + memcpy(cmd_hdr->uid, uid, sizeof(cmd_hdr->uid)); + + g_free(uid); + + return 0; +} + +static int t5_check_resp(uint8_t *resp, int length) +{ + struct type5_err_resp *t5_err_resp = + (struct type5_err_resp *)(resp + NFC_HEADER_SIZE); + int err = 0; + + DBG(""); + + if (length < 0) { + near_error("Cmd failure: %d", length); + err = length; + } else if (resp[0]) { + near_error("NFC Failure: 0x%x", resp[0]); + err = -EIO; + } else { + length -= NFC_HEADER_SIZE; + + if (t5_err_resp->flags & RESP_FLAG_ERR) { + if (length == 2) + near_error("Tag failure: 0x%x", + t5_err_resp->err_code); + else + near_error("Tag failure: Cause unknown"); + + err = -EIO; + } + } + + return err; +} + +static struct t5_cookie *t5_cookie_alloc(struct near_tag *tag) +{ + struct t5_cookie *cookie; + + cookie = g_try_malloc0(sizeof(*cookie)); + if (!cookie) + return NULL; + + cookie->tag = tag; + + return cookie; +} + +static int t5_cookie_release(int err, void *data) +{ + struct t5_cookie *cookie = data; + + DBG("%p", cookie); + + if (!cookie) + return err; + + else if (cookie->cb) + cookie->cb(near_tag_get_adapter_idx(cookie->tag), + near_tag_get_target_idx(cookie->tag), err); + + if (cookie->ndef) { + g_free(cookie->ndef->data); + g_free(cookie->ndef); + } + + g_free(cookie); + + return err; +} + +/* + * Provide "local" read and write routines that take care of reading + * or writing 'n' bytes from/to the tag. + */ +static int t5_cookie_release_local(int err, void *data) +{ + struct t5_cookie *cookie = data; + + DBG("%p", cookie); + + if (!cookie) + return err; + + if (cookie->local_cb) + cookie->local_cb(cookie->tag, err, cookie->local_cb_data); + + g_free(cookie); + + return err; +} + +static int t5_read_resp(uint8_t *resp, int length, void *data) +{ + struct type5_read_single_block_resp *t5_resp = + (struct type5_read_single_block_resp *)(resp + NFC_HEADER_SIZE); + struct type5_read_single_block_cmd t5_cmd; + struct t5_cookie *cookie = data; + struct near_tag *tag = cookie->tag; + uint8_t blk_size = near_tag_get_blk_size(tag); + int err; + + DBG("length: %d", length); + + err = t5_check_resp(resp, length); + if (err) + goto out_done; + + length -= NFC_HEADER_SIZE; + + if (length != (int)(sizeof(*t5_resp) + blk_size)) { + near_error("Read - Invalid response - length: %d", length); + err = -EIO; + goto out_done; + } + + length = blk_size - cookie->src_offset; + length = MIN(length, (int)cookie->bytes_left); + + memcpy(&cookie->buf[cookie->dst_offset], + &t5_resp->data[cookie->src_offset], length); + + if (cookie->bytes_left <= blk_size) + goto out_done; + + cookie->bytes_left -= length; + cookie->src_offset = 0; + cookie->dst_offset += length; + cookie->blk++; + + err = t5_cmd_hdr_init(tag, &t5_cmd.hdr, CMD_READ_SINGLE_BLOCK); + if (err) + goto out_done; + + t5_cmd.blk_no = cookie->blk; + + return near_adapter_send(near_tag_get_adapter_idx(tag), + (uint8_t *)&t5_cmd, sizeof(t5_cmd), t5_read_resp, + cookie, t5_cookie_release_local); + +out_done: + DBG("Done reading: %d", err); + + return t5_cookie_release_local(err, cookie); +} + +static int t5_read(struct near_tag *tag, uint8_t offset, uint8_t *buf, + size_t len, t5_local_cb local_cb, void *local_data) +{ + struct type5_read_single_block_cmd t5_cmd; + struct t5_cookie *cookie = local_data; + uint8_t blk_size = near_tag_get_blk_size(tag); + int err; + + DBG("Reading %zd bytes starting at offset %d\n", len, offset); + + err = t5_cmd_hdr_init(tag, &t5_cmd.hdr, CMD_READ_SINGLE_BLOCK); + if (err) + return err; + + t5_cmd.blk_no = offset / blk_size; + + cookie = t5_cookie_alloc(tag); + if (!cookie) + return -ENOMEM; + + cookie->local_cb = local_cb; + cookie->local_cb_data = local_data; + cookie->buf = buf; + cookie->src_offset = offset - (t5_cmd.blk_no * blk_size); + cookie->dst_offset = 0; + cookie->bytes_left = len; + cookie->blk = t5_cmd.blk_no; + + return near_adapter_send(near_tag_get_adapter_idx(tag), + (uint8_t *)&t5_cmd, sizeof(t5_cmd), t5_read_resp, + cookie, t5_cookie_release_local); +} + +static int t5_write_resp(uint8_t *resp, int length, void *data) +{ + struct type5_write_single_block_resp *t5_resp = + (struct type5_write_single_block_resp *) + (resp + NFC_HEADER_SIZE); + struct type5_write_single_block_cmd *t5_cmd = NULL; + struct t5_cookie *cookie = data; + struct near_tag *tag = cookie->tag; + uint8_t blk_size = near_tag_get_blk_size(tag); + int err; + + DBG("length: %d", length); + + err = t5_check_resp(resp, length); + if (err) + goto out_done; + + length -= NFC_HEADER_SIZE; + + if (length != sizeof(*t5_resp)) { + near_error("Wrte - Invalid response - length: %d", length); + err = -EIO; + goto out_done; + } + + if (cookie->bytes_left <= blk_size) + goto out_done; + + cookie->bytes_left -= blk_size; + cookie->src_offset += blk_size; + cookie->blk++; + + t5_cmd = g_try_malloc0(sizeof(*t5_cmd) + blk_size); + if (!t5_cmd) { + err = -ENOMEM; + goto out_done; + } + + err = t5_cmd_hdr_init(tag, &t5_cmd->hdr, + CMD_WRITE_SINGLE_BLOCK); + if (err) + goto out_done; + + t5_cmd->blk_no = cookie->blk; + memcpy(t5_cmd->data, &cookie->buf[cookie->src_offset], blk_size); + + err = near_adapter_send(near_tag_get_adapter_idx(tag), + (uint8_t *)t5_cmd, sizeof(*t5_cmd) + blk_size, + t5_write_resp, cookie, t5_cookie_release_local); + + g_free(t5_cmd); + return err; + +out_done: + DBG("Done writing: %d", err); + + if (t5_cmd) + g_free(t5_cmd); + + return t5_cookie_release_local(err, cookie); +} + +static int t5_write(struct near_tag *tag, uint8_t offset, uint8_t *buf, + size_t len, t5_local_cb local_cb, void *local_data) +{ + struct type5_write_single_block_cmd *t5_cmd; + struct t5_cookie *cookie = local_data; + uint8_t blk_size = near_tag_get_blk_size(tag); + int err; + + DBG("Writing %zd bytes starting at offset %d\n", len, offset); + + if (offset % blk_size) { + near_error("Write - Invalid offset - offset: %d, blk_size: %d", + offset, blk_size); + return -EINVAL; + } + + t5_cmd = g_try_malloc0(sizeof(*t5_cmd) + blk_size); + if (!t5_cmd) + return -ENOMEM; + + err = t5_cmd_hdr_init(tag, &t5_cmd->hdr, CMD_WRITE_SINGLE_BLOCK); + if (err) + goto out_err; + + t5_cmd->blk_no = offset / blk_size; + memcpy(t5_cmd->data, buf, blk_size); + + cookie = t5_cookie_alloc(tag); + if (!cookie) { + err = -ENOMEM; + goto out_err; + } + + cookie->local_cb = local_cb; + cookie->local_cb_data = local_data; + cookie->buf = buf; + cookie->src_offset = 0; + cookie->bytes_left = len; + cookie->blk = t5_cmd->blk_no; + + err = near_adapter_send(near_tag_get_adapter_idx(tag), + (uint8_t *)t5_cmd, sizeof(*t5_cmd) + blk_size, + t5_write_resp, cookie, t5_cookie_release_local); + +out_err: + g_free(t5_cmd); + return err; +} + +/* + * The remaining routines implement the read, write, check_presence, + * and format plugin hooks + */ +static int t5_read_data_resp(struct near_tag *tag, int err, void *data) +{ + struct t5_cookie *cookie = data; + size_t data_length; + uint8_t *nfc_data; + GList *records; + + DBG(""); + + if (err) + goto out_err; + + nfc_data = near_tag_get_data(tag, &data_length); + if (!nfc_data) { + err = -ENOMEM; + goto out_err; + } + + records = near_tlv_parse(nfc_data, data_length); + near_tag_add_records(tag, records, NULL, 0); + +out_err: + return t5_cookie_release(err, cookie); +} + +static bool t5_cc_is_valid(struct type5_cc *t5_cc) +{ + bool valid = false; + + if ((t5_cc->cc0 == TYPE5_CC0_NDEF_MAGIC) && + (TYPE5_CC1_VER_GET_MAJOR(t5_cc->cc1) == + TYPE5_VERSION_MAJOR) && + (TYPE5_CC1_VER_GET_MINOR(t5_cc->cc1) == + TYPE5_VERSION_MINOR)) + valid = true; + + return valid; +} + +static size_t t5_cc_get_data_length(struct type5_cc *t5_cc) +{ + return t5_cc->cc2 * 8; +} + +static bool t5_cc_is_read_only(struct type5_cc *t5_cc) +{ + return (t5_cc->cc1 & TYPE5_CC1_WRITE_ACCESS_MASK) != + TYPE5_CC1_WRITE_ACCESS_ALWAYS; +} + +static int t5_read_multiple_blocks_resp(uint8_t *resp, int length, void *data) +{ + struct type5_read_multiple_blocks_resp *t5_resp = + (struct type5_read_multiple_blocks_resp *) + (resp + NFC_HEADER_SIZE); + struct t5_cookie *cookie = data; + struct near_tag *tag = cookie->tag; + uint8_t blk_size = near_tag_get_blk_size(tag); + size_t data_length; + GList *records; + int err; + + DBG(""); + + cookie->buf = near_tag_get_data(tag, &data_length); + + err = t5_check_resp(resp, length); + if (err) + goto out_done; + + length -= NFC_HEADER_SIZE; + + if (length != (int)(sizeof(*t5_resp) + + (cookie->nb_requested_blocks * blk_size))) { + err = -EIO; + goto out_done; + } + + /* Copy length - 2 bytes (-2 because of RMB header) */ + memcpy(cookie->buf, t5_resp->data, length - 2); + + records = near_tlv_parse(cookie->buf, data_length); + near_tag_add_records(tag, records, NULL, 0); + +out_done: + return t5_cookie_release(err, cookie); +} + +static int t5_read_multiple_blocks(struct near_tag *tag, + uint8_t starting_block, + uint8_t number_of_blocks, + near_recv rx_cb, + struct t5_cookie *cookie) +{ + struct type5_read_multiple_blocks_cmd t5_cmd; + int err; + + DBG(""); + + err = t5_cmd_hdr_init(tag, &t5_cmd.hdr, CMD_READ_MULITPLE_BLOCKS); + if (err) + return err; + + t5_cmd.blk_no = starting_block; + t5_cmd.num_blks = number_of_blocks - 1; + + return near_adapter_send(near_tag_get_adapter_idx(tag), + (uint8_t *)&t5_cmd, sizeof(t5_cmd), + rx_cb, cookie, t5_cookie_release); +} + +static int t5_read_meta_resp(struct near_tag *tag, int err, void *data) +{ + struct t5_cookie *cookie = data; + struct type5_cc *t5_cc; + size_t data_length; + uint8_t *tag_data; + uint16_t first_block; + int rmb_supported; + + DBG(""); + + if (err) + goto out_err; + + t5_cc = (struct type5_cc *)cookie->buf; + + if (t5_cc_is_valid(t5_cc)) { + data_length = t5_cc_get_data_length(t5_cc) - + TYPE5_DATA_START_OFFSET(tag); + + err = near_tag_add_data(near_tag_get_adapter_idx(tag), + near_tag_get_target_idx(tag), NULL, + data_length); + if (err) + goto out_err; + + tag_data = near_tag_get_data(tag, &data_length); + if (!tag_data) { + err = -EIO; + goto out_err; + } + + near_tag_set_blank(tag, FALSE); + + if (t5_cc_is_read_only(t5_cc)) + near_tag_set_ro(tag, TRUE); + else + near_tag_set_ro(tag, FALSE); + + rmb_supported = t5_cc->cc3 & TYPE5_CC3_MBREAD_FLAG; + + g_free(cookie->buf); + + if (rmb_supported) { + first_block = TYPE5_DATA_START_OFFSET(tag) / + near_tag_get_blk_size(tag); + cookie->nb_requested_blocks = + near_tag_get_num_blks(tag) - first_block; + err = t5_read_multiple_blocks(tag, first_block, + cookie->nb_requested_blocks, + t5_read_multiple_blocks_resp, + cookie); + } else { + err = t5_read(tag, TYPE5_DATA_START_OFFSET(tag), + tag_data, data_length, t5_read_data_resp, + cookie); + } + + if (err < 0) + err = t5_cookie_release(err, cookie); + + return err; + } else { + DBG("Mark as blank tag"); + near_tag_set_blank(tag, TRUE); + } + +out_err: + g_free(cookie->buf); + return t5_cookie_release(err, cookie); +} + +static int t5_read_meta(struct near_tag *tag, struct t5_cookie *cookie) +{ + uint8_t *buf; + int err; + + DBG(""); + + buf = g_try_malloc0(TYPE5_LEN_CC_BYTES); + if (!buf) + return -ENOMEM; + + cookie->buf = buf; + + err = t5_read(tag, TYPE5_META_START_OFFSET, buf, TYPE5_LEN_CC_BYTES, + t5_read_meta_resp, cookie); + if (err < 0) + g_free(buf); + + return err; +} + +static int t5_get_sys_info_resp(uint8_t *resp, int length, void *data) +{ + struct type5_get_system_info_resp *t5_resp = + (struct type5_get_system_info_resp *)(resp + NFC_HEADER_SIZE); + struct t5_cookie *cookie = data; + struct near_tag *tag = cookie->tag; + uint8_t offset = 0; + int err; + + DBG("length: %d", length); + + err = t5_check_resp(resp, length); + if (err) + goto out_err; + + length -= NFC_HEADER_SIZE; + + if (length < (int)sizeof(*t5_resp)) { + near_error("Get System Info - Invalid response - length: %d", + length); + err = -EIO; + goto out_err; + } + + if (t5_resp->info_flags & GET_SYS_INFO_FLAG_DSFID) + offset++; + + if (t5_resp->info_flags & GET_SYS_INFO_FLAG_AFI) + offset++; + + if (t5_resp->info_flags & GET_SYS_INFO_FLAG_MEM_SIZE) { + if (t5_resp->info_flags & GET_SYS_INFO_FLAG_16B_NB_BLOCK) { + near_tag_set_num_blks(tag, (t5_resp->data[offset] | + (t5_resp->data[offset + 1] << 8)) + 1); + offset += 2; + } else + near_tag_set_num_blks(tag, t5_resp->data[offset++] + 1); + near_tag_set_blk_size(tag, + (t5_resp->data[offset++] & 0x1f) + 1); + } else { /* Tag must provide memory size info */ + err = -EIO; + goto out_err; + } + + err = t5_read_meta(tag, cookie); + +out_err: + if (err < 0) + err = t5_cookie_release(err, cookie); + + return err; +} + +static int t5_get_sys_info(struct near_tag *tag, struct t5_cookie *cookie) +{ + struct type5_get_system_info_cmd t5_cmd; + int err; + + DBG(""); + + err = t5_cmd_hdr_init(tag, &t5_cmd.hdr, CMD_GET_SYSTEM_INFO); + if (err) + return err; + + return near_adapter_send(near_tag_get_adapter_idx(tag), + (uint8_t *)&t5_cmd, sizeof(t5_cmd), + t5_get_sys_info_resp, cookie, NULL); +} + +static int nfctype5_read(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb) +{ + struct t5_cookie *cookie; + struct near_tag *tag; + int err; + + DBG(""); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + cookie = t5_cookie_alloc(tag); + if (!cookie) { + err = -ENOMEM; + goto out_err; + } + + cookie->cb = cb; + + /* + * Only need to call t5_get_sys_info() to get the blk_size and + * num_blks once. near_tag_get_blk_size() will return 0 if + * t5_get_sys_info() hasn't been called yet. + */ + if (near_tag_get_blk_size(tag)) + err = t5_read_meta(tag, cookie); + else + err = t5_get_sys_info(tag, cookie); + + if (err < 0) + err = t5_cookie_release(err, cookie); + + return err; + +out_err: + if (cb) + cb(adapter_idx, target_idx, err); + + return err; +} + +static int nfctype5_write_resp(struct near_tag *tag, int err, void *data) +{ + struct t5_cookie *cookie = data; + + DBG(""); + + return t5_cookie_release(err, cookie); +} + +static int nfctype5_write(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, near_tag_io_cb cb) +{ + struct t5_cookie *cookie; + struct near_tag *tag; + int err; + + DBG(""); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + cookie = t5_cookie_alloc(tag); + if (!cookie) { + err = -ENOMEM; + goto out_err; + } + + cookie->cb = cb; + cookie->ndef = ndef; + + if ((ndef->length) > near_tag_get_data_length(tag)) { + near_error("Not enough space on tag %zd %zd", + ndef->length, + near_tag_get_data_length(tag)); + err = -ENOSPC; + goto out_err; + } + + err = t5_write(tag, TYPE5_DATA_START_OFFSET(tag), + ndef->data + ndef->offset, ndef->length, + nfctype5_write_resp, cookie); + if (err < 0) + err = t5_cookie_release(err, cookie); + + return err; + +out_err: + if (cb) + cb(adapter_idx, target_idx, err); + + return err; +} + +static int nfctype5_check_presence_resp(struct near_tag *tag, int err, + void *data) +{ + struct t5_cookie *cookie = data; + + DBG("err: %d", err); + + g_free(cookie->buf); + + return t5_cookie_release(err, cookie); +} + +static int nfctype5_check_presence(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb) +{ + struct t5_cookie *cookie; + struct near_tag *tag; + uint8_t *buf; + int err; + + DBG(""); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + cookie = t5_cookie_alloc(tag); + if (!cookie) { + err = -ENOMEM; + goto out_err; + } + + cookie->cb = cb; + + buf = g_try_malloc0(1); + if (!buf) { + err = -ENOMEM; + return t5_cookie_release(err, cookie); + } + + cookie->buf = buf; + + err = t5_read(tag, 0, buf, 1, nfctype5_check_presence_resp, cookie); + if (err < 0) { + g_free(buf); + err = t5_cookie_release(err, cookie); + } + + return err; + +out_err: + if (cb) + cb(adapter_idx, target_idx, err); + + return err; +} + +static int nfctype5_format_resp(struct near_tag *tag, int err, void *data) +{ + struct t5_cookie *cookie = data; + + DBG(""); + + if (!err) { + DBG("Done formatting"); + near_tag_set_blank(tag, FALSE); + } else { + near_error("Format Failed"); + } + + return t5_cookie_release(err, cookie); +} + +static int t5_format_read_multiple_blocks_resp(uint8_t *resp, int length, + void *data) +{ + struct type5_read_multiple_blocks_resp *t5_resp = + (struct type5_read_multiple_blocks_resp *) + (resp + NFC_HEADER_SIZE); + struct t5_cookie *cookie = data; + struct type5_cc t5_cc; + struct near_tag *tag = cookie->tag; + uint8_t blk_size = near_tag_get_blk_size(tag); + size_t mem_size; + bool read_multiple_supported = false; + int err; + + DBG(""); + + err = t5_check_resp(resp, length); + if (!err) { + length -= NFC_HEADER_SIZE; + + if (length == (int)(sizeof(*t5_resp) + (2 * blk_size))) + read_multiple_supported = true; + } + + t5_cc.cc0 = TYPE5_CC0_NDEF_MAGIC; + + t5_cc.cc1 = TYPE5_VERSION_MAJOR << TYPE5_CC1_VER_MAJOR_SHIFT; + t5_cc.cc1 |= TYPE5_VERSION_MINOR << TYPE5_CC1_VER_MINOR_SHIFT; + t5_cc.cc1 |= TYPE5_CC1_READ_ACCESS_ALWAYS; + + /* + * Assume that the tag is *not* read only because if it is, the tag + * would have to be formatted already and we wouldn't be here. + * Besides, if it is read only then the write below will fail and + * the CC won't be changed anyway. + */ + t5_cc.cc1 |= TYPE5_CC1_WRITE_ACCESS_ALWAYS; + + mem_size = blk_size * near_tag_get_num_blks(tag); + mem_size = MIN(mem_size, TYPE5_MAX_MEM_SIZE); + + t5_cc.cc2 = mem_size / 8; + + /* + * We cannot set the lock flag in CC3. The reason is that to know + * if LOCK operations are supported, we'd have to perform one. + * But performing one will permanently LOCK that block so instead + * just say that its not supported. We also don't know whether + * the tag needs a special frame format so just say "no" for that + * one too. If it does, we probably can't write to the tag anyway. + */ + t5_cc.cc3 = 0; + + if (read_multiple_supported) + t5_cc.cc3 |= TYPE5_CC3_MBREAD_FLAG; + + err = t5_write(tag, TYPE5_META_START_OFFSET, (uint8_t *)&t5_cc, + sizeof(t5_cc), nfctype5_format_resp, cookie); + if (err < 0) + err = t5_cookie_release(err, cookie); + + return err; +} + +static int nfctype5_format(uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb) +{ + struct t5_cookie *cookie; + struct near_tag *tag; + int err; + + DBG(""); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) { + err = -EINVAL; + goto out_err; + } + + cookie = t5_cookie_alloc(tag); + if (!cookie) { + err = -ENOMEM; + goto out_err; + } + + cookie->cb = cb; + + return t5_read_multiple_blocks(tag, 0, 2, + t5_format_read_multiple_blocks_resp, + cookie); + +out_err: + if (cb) + cb(adapter_idx, target_idx, err); + + return err; +} + +static struct near_tag_driver type5_driver = { + .type = NFC_PROTO_ISO15693, + .priority = NEAR_TAG_PRIORITY_DEFAULT, + .read = nfctype5_read, + .write = nfctype5_write, + .check_presence = nfctype5_check_presence, + .format = nfctype5_format, +}; + +static int nfctype5_init(void) +{ + DBG(""); + + return near_tag_driver_register(&type5_driver); +} + +static void nfctype5_exit(void) +{ + DBG(""); + + near_tag_driver_unregister(&type5_driver); +} + +NEAR_PLUGIN_DEFINE(nfctype5, "ISO 15693 (NFC Type 5) tags support", VERSION, + NEAR_PLUGIN_PRIORITY_HIGH, nfctype5_init, nfctype5_exit)
diff --git a/neard/plugins/npp.c b/neard/plugins/npp.c new file mode 100644 index 0000000..6bed302 --- /dev/null +++ b/neard/plugins/npp.c
@@ -0,0 +1,215 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/device.h> +#include <near/ndef.h> +#include <near/tlv.h> + +#include "p2p.h" + +struct p2p_npp_ndef_entry { + uint8_t action; + uint32_t ndef_length; + uint8_t ndef[]; +} __attribute__((packed)); + +struct p2p_npp_frame { + uint8_t version; + uint32_t n_ndef; + struct p2p_npp_ndef_entry ndefs[]; +} __attribute__((packed)); + +#define NPP_MAJOR_VERSION (0x0 & 0xf) +#define NPP_MINOR_VERSION 0x1 +#define NPP_VERSION ((NPP_MAJOR_VERSION << 4) | NPP_MINOR_VERSION) + +#define NPP_DEFAULT_ACTION 0x1 + +static bool npp_read(int client_fd, + uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, gpointer data) +{ + struct near_device *device; + struct p2p_npp_frame frame; + struct p2p_npp_ndef_entry entry; + int bytes_recv, n_ndef, i, ndef_length, total_ndef_length, err; + uint8_t *ndefs, *new_ndefs, *current_ndef; + GList *records; + + ndefs = NULL; + total_ndef_length = 0; + err = 0; + + bytes_recv = recv(client_fd, &frame, sizeof(frame), 0); + if (bytes_recv < 0) { + near_error("Could not read NPP frame %d", bytes_recv); + return bytes_recv; + } + + n_ndef = GINT_FROM_BE(frame.n_ndef); + + DBG("version %d %d NDEFs", frame.version, n_ndef); + + if (frame.version != NPP_VERSION) { + near_error("Invalid NPP version 0x%x", frame.version); + return false; + } + + for (i = 0; i < n_ndef; i++) { + bytes_recv = recv(client_fd, &entry, sizeof(entry), 0); + if (bytes_recv < 0) { + near_error("Could not read NPP NDEF entry %d", + bytes_recv); + err = bytes_recv; + break; + } + + ndef_length = GINT_FROM_BE(entry.ndef_length); + total_ndef_length += ndef_length + TLV_SIZE; + DBG("NDEF %d length %d", i, ndef_length); + + new_ndefs = g_try_realloc(ndefs, total_ndef_length); + if (!new_ndefs) { + near_error("Could not allocate NDEF buffer %d", + bytes_recv); + err = -ENOMEM; + break; + } + ndefs = new_ndefs; + + current_ndef = ndefs + total_ndef_length + - (ndef_length + TLV_SIZE); + current_ndef[0] = TLV_NDEF; + current_ndef[1] = ndef_length; + + bytes_recv = recv(client_fd, current_ndef + TLV_SIZE, + ndef_length, 0); + if (bytes_recv < 0) { + near_error("Could not read NDEF entry %d", + bytes_recv); + err = bytes_recv; + break; + } + } + + if (total_ndef_length == 0) + return err; + + DBG("Total NDEF length %d", total_ndef_length); + + err = near_device_add_data(adapter_idx, target_idx, + ndefs, total_ndef_length); + if (err < 0) + return false; + + device = near_device_get_device(adapter_idx, target_idx); + if (!device) { + g_free(ndefs); + return -ENOMEM; + } + + for (i = 0; i < total_ndef_length; i++) + DBG("NDEF[%d] 0x%x", i, ndefs[i]); + + records = near_tlv_parse(ndefs, total_ndef_length); + near_device_add_records(device, records, cb, 0); + + g_free(ndefs); + + return false; +} + +static int npp_push(int fd, uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_device_io_cb cb, + gpointer data) +{ + struct p2p_npp_frame *frame; + struct p2p_npp_ndef_entry *entry; + size_t frame_length; + int err; + + DBG(""); + + frame_length = sizeof(struct p2p_npp_frame) + + sizeof(struct p2p_npp_ndef_entry) + + ndef->length; + frame = g_try_malloc0(frame_length); + if (!frame) + return -ENOMEM; + + entry = &frame->ndefs[0]; + + frame->version = NPP_VERSION; + frame->n_ndef = GINT_TO_BE(1); + + entry->action = NPP_DEFAULT_ACTION; + entry->ndef_length = GINT_TO_BE(ndef->length); + memcpy(entry->ndef, ndef->data, ndef->length); + + DBG("Sending %zd bytes", frame_length); + + err = send(fd, frame, frame_length, MSG_DONTWAIT); + + g_free(frame); + + cb(adapter_idx, target_idx, err < 0 ? err : 0); + + close(fd); + + return err; +} + +struct near_p2p_driver npp_driver = { + .name = "NPP", + .service_name = NEAR_DEVICE_SN_NPP, + .fallback_service_name = NULL, + .sock_type = SOCK_STREAM, + .read = npp_read, + .push = npp_push, +}; + +int npp_init(void) +{ + return near_p2p_register(&npp_driver); +} + +void npp_exit(void) +{ + near_p2p_unregister(&npp_driver); +}
diff --git a/neard/plugins/p2p.c b/neard/plugins/p2p.c new file mode 100644 index 0000000..13702ad --- /dev/null +++ b/neard/plugins/p2p.c
@@ -0,0 +1,680 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <unistd.h> +#include <stdint.h> +#include <stdbool.h> +#include <errno.h> +#include <string.h> +#include <poll.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/tag.h> +#include <near/device.h> +#include <near/adapter.h> +#include <near/tlv.h> +#include <near/ndef.h> + +#include "p2p.h" + +static GSList *driver_list = NULL; +static GList *server_list = NULL; + +struct p2p_data { + struct near_p2p_driver *driver; + uint32_t adapter_idx; + uint32_t target_idx; + near_device_io_cb cb; + int fd; + guint watch; + struct p2p_data *server; + + GList *client_list; +}; + +/* common function for socket binding */ +static int __p2p_bind(struct p2p_data *server_data, GIOFunc listener) +{ + int err, fd = server_data->fd; + struct sockaddr_nfc_llcp addr; + GIOChannel *channel; + struct near_p2p_driver *driver = server_data->driver; + + DBG("Binding %s", driver->name); + + memset(&addr, 0, sizeof(struct sockaddr_nfc_llcp)); + addr.sa_family = AF_NFC; + addr.dev_idx = server_data->adapter_idx; + addr.nfc_protocol = NFC_PROTO_NFC_DEP; + addr.service_name_len = strlen(driver->service_name); + strcpy(addr.service_name, driver->service_name); + + err = bind(fd, (struct sockaddr *) &addr, + sizeof(struct sockaddr_nfc_llcp)); + if (err < 0) { + if (errno == EADDRINUSE) { + DBG("%s is already bound", driver->name); + err = 0; + goto out_err; + } + + near_error("%s bind failed %d %d", driver->name, err, errno); + goto out_err; + } + + if (server_data->driver->sock_type == SOCK_STREAM) { + err = listen(fd, 10); + if (err < 0) { + near_error("%s listen failed %d", driver->name, err); + goto out_err; + } + } + + channel = g_io_channel_unix_new(fd); + g_io_channel_set_close_on_unref(channel, TRUE); + + server_data->watch = g_io_add_watch(channel, + G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR, + listener, (gpointer) server_data); + g_io_channel_unref(channel); + + return 0; + +out_err: + close(fd); + return err; +} + +static gboolean p2p_listener_event(GIOChannel *channel, GIOCondition condition, + gpointer user_data); + +struct p2p_connect { + uint32_t adapter_idx; + uint32_t target_idx; + guint watch; + struct near_p2p_driver *driver; + struct near_ndef_message *ndef; + near_device_io_cb cb; +}; + +static gboolean p2p_client_event(GIOChannel *channel, GIOCondition condition, + gpointer user_data) +{ + struct p2p_data *client_data = user_data; + + DBG("condition 0x%x", condition); + + if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { + int err; + struct p2p_data *server_data = client_data->server; + + if (client_data->watch > 0) + g_source_remove(client_data->watch); + client_data->watch = 0; + + if (condition & (G_IO_NVAL | G_IO_ERR)) + err = -EIO; + else + err = 0; + + if (client_data->driver->close) + client_data->driver->close(client_data->fd, err, + client_data->driver->user_data); + + near_error("%s client channel closed", + client_data->driver->name); + + if (server_data) + server_data->client_list = + g_list_remove(server_data->client_list, + client_data); + + if (client_data->driver->single_connection) { + server_data->fd = socket(AF_NFC, SOCK_STREAM, + NFC_SOCKPROTO_LLCP); + if (server_data->fd > 0) + __p2p_bind(server_data, p2p_listener_event); + } + + if (client_data->driver->sock_type == SOCK_STREAM) + g_free(client_data); + + return FALSE; + } + + if (client_data->driver->new_client) + return true; + + return client_data->driver->read(client_data->fd, + client_data->adapter_idx, + client_data->target_idx, + client_data->cb, + client_data->driver->user_data); + +} + +static void free_client_data(gpointer data) +{ + struct p2p_data *client_data; + + DBG(""); + + client_data = (struct p2p_data *) data; + + if (client_data->driver->close) + client_data->driver->close(client_data->fd, 0, + client_data->driver->user_data); + + if (client_data->watch > 0) + g_source_remove(client_data->watch); + + g_free(client_data); +} + +static void free_server_data(gpointer data) +{ + struct p2p_data *server_data; + + DBG(""); + + server_data = (struct p2p_data *)data; + + if (server_data->watch > 0) + g_source_remove(server_data->watch); + server_data->watch = 0; + g_list_free_full(server_data->client_list, free_client_data); + server_data->client_list = NULL; + + DBG("Closing server socket"); + + close(server_data->fd); + + g_free(server_data); +} + +static gboolean p2p_listener_event(GIOChannel *channel, GIOCondition condition, + gpointer user_data) +{ + struct sockaddr_nfc_llcp client_addr; + socklen_t client_addr_len; + int server_fd, client_fd; + struct p2p_data *client_data, *server_data = user_data; + GIOChannel *client_channel; + struct near_p2p_driver *driver = server_data->driver; + + DBG("condition 0x%x", condition); + + server_fd = g_io_channel_unix_get_fd(channel); + + if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { + if (server_data->watch > 0) + g_source_remove(server_data->watch); + server_data->watch = 0; + + g_list_free_full(server_data->client_list, free_client_data); + server_data->client_list = NULL; + + near_error("Error with %s server channel", driver->name); + + return FALSE; + } + + client_addr_len = sizeof(client_addr); + client_fd = accept(server_fd, (struct sockaddr *) &client_addr, + &client_addr_len); + if (client_fd < 0) { + near_error("accept failed %d", client_fd); + + return FALSE; + } + + DBG("client dsap %d ssap %d", + client_addr.dsap, client_addr.ssap); + DBG("target idx %d", client_addr.target_idx); + + client_data = g_try_malloc0(sizeof(struct p2p_data)); + if (!client_data) { + close(client_fd); + return FALSE; + } + + client_data->driver = server_data->driver; + client_data->adapter_idx = server_data->adapter_idx; + client_data->target_idx = client_addr.target_idx; + client_data->fd = client_fd; + client_data->cb = server_data->cb; + client_data->server = server_data; + + client_channel = g_io_channel_unix_new(client_fd); + g_io_channel_set_close_on_unref(client_channel, TRUE); + + /* This would enable passthru active */ + if (server_data->driver->new_client) + server_data->driver->new_client( + client_data->driver->service_name, client_fd, + server_data->driver->user_data); + + client_data->watch = g_io_add_watch(client_channel, + G_IO_IN | G_IO_HUP | G_IO_NVAL | G_IO_ERR, + p2p_client_event, + client_data); + + g_io_channel_unref(client_channel); + + server_data->client_list = g_list_append(server_data->client_list, + client_data); + + return !driver->single_connection; +} + +static int p2p_connect_blocking(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_device_io_cb cb, + struct near_p2p_driver *driver) +{ + int fd, err = 0; + struct timeval timeout; + struct sockaddr_nfc_llcp addr; + + DBG(""); + + fd = socket(AF_NFC, SOCK_STREAM, NFC_SOCKPROTO_LLCP); + if (fd < 0) + return -errno; + + memset(&addr, 0, sizeof(struct sockaddr_nfc_llcp)); + addr.sa_family = AF_NFC; + addr.dev_idx = adapter_idx; + addr.target_idx = target_idx; + addr.nfc_protocol = NFC_PROTO_NFC_DEP; + addr.service_name_len = strlen(driver->service_name); + strcpy(addr.service_name, driver->service_name); + + timeout.tv_sec = 8; + timeout.tv_usec = 0; + + if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, + sizeof(timeout)) < 0) + near_error("Could not set the receive timeout\n"); + + if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, + sizeof(timeout)) < 0) + near_error("Could not set the send timeout\n"); + + err = connect(fd, (struct sockaddr *) &addr, + sizeof(struct sockaddr_nfc_llcp)); + if (err < 0) { + near_error("Connect failed %d", err); + close(fd); + + return err; + } + + return fd; +} + +static gboolean p2p_push_blocking(gpointer user_data) +{ + struct p2p_connect *conn = user_data; + int fd, err; + + DBG(""); + + fd = p2p_connect_blocking(conn->adapter_idx, conn->target_idx, + conn->ndef, conn->cb, conn->driver); + if (fd < 0) { + err = fd; + goto out; + } + + err = conn->driver->push(fd, conn->adapter_idx, conn->target_idx, + conn->ndef, conn->cb, + conn->driver->user_data); + +out: + if (err < 0) + conn->cb(conn->adapter_idx, conn->target_idx, err); + + g_free(conn->ndef->data); + g_free(conn->ndef); + g_free(conn); + + return FALSE; +} + +static bool check_nval(GIOChannel *io) +{ + struct pollfd fds; + + memset(&fds, 0, sizeof(fds)); + fds.fd = g_io_channel_unix_get_fd(io); + fds.events = POLLNVAL; + + if (poll(&fds, 1, 0) > 0 && (fds.revents & POLLNVAL)) + return true; + + return false; +} + +static gboolean p2p_connect_event(GIOChannel *channel, GIOCondition condition, + gpointer user_data) +{ + struct p2p_connect *conn = user_data; + int err, sk_err, fd; + socklen_t len = sizeof(sk_err); + + DBG("condition 0x%x", condition); + + if (!conn->driver->push) { + err = -EOPNOTSUPP; + goto out; + } + + fd = g_io_channel_unix_get_fd(channel); + + if ((condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) || + check_nval(channel)) { + near_error("%s connect error", conn->driver->name); + + if (condition & G_IO_HUP) { + DBG("Trying a blocking connect"); + + close(fd); + + g_timeout_add(300, p2p_push_blocking, conn); + + return FALSE; + } + + err = -EIO; + goto out; + } + + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0) + err = -errno; + else + err = -sk_err; + if (err < 0) { + near_error("%s Connection error %d", + conn->driver->name, -err); + goto out; + } + + err = conn->driver->push(fd, conn->adapter_idx, conn->target_idx, + conn->ndef, conn->cb, + conn->driver->user_data); + +out: + if (err < 0) + conn->cb(conn->adapter_idx, conn->target_idx, err); + + g_free(conn->ndef->data); + g_free(conn->ndef); + g_free(conn); + + return FALSE; +} + +static int p2p_bind(struct near_p2p_driver *driver, uint32_t adapter_idx, + near_device_io_cb cb) +{ + int err, fd; + struct p2p_data *server_data; + GIOFunc g_func; + + DBG(""); + + if (driver->sock_type == SOCK_DGRAM) + g_func = p2p_client_event; + else + g_func = p2p_listener_event; + + if (driver->sock_type != SOCK_DGRAM && + driver->sock_type != SOCK_STREAM) { + near_error("Undefined socket type for %s ", driver->name); + return -EINVAL; + } + + fd = socket(AF_NFC, driver->sock_type, NFC_SOCKPROTO_LLCP); + if (fd < 0) + return -errno; + + server_data = g_try_malloc0(sizeof(struct p2p_data)); + if (!server_data) { + close(fd); + return -ENOMEM; + } + + server_data->driver = driver; + server_data->adapter_idx = adapter_idx; + server_data->fd = fd; + server_data->cb = cb; + + err = __p2p_bind(server_data, g_func); + if (err < 0) { + g_free(server_data); + return err; + } + + server_list = g_list_append(server_list, server_data); + + return 0; +} + +static int p2p_listen(uint32_t adapter_idx, near_device_io_cb cb) +{ + int err = -1, bind_err; + GSList *list; + + for (list = driver_list; list; list = list->next) { + struct near_p2p_driver *driver = list->data; + + bind_err = p2p_bind(driver, adapter_idx, cb); + if (bind_err == 0) { + err = 0; + } else if (bind_err == -EPROTONOSUPPORT) { + near_error("LLCP is not supported"); + return bind_err; + } + } + + return err; +} + +static int p2p_connect(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_device_io_cb cb, struct near_p2p_driver *driver) +{ + int fd, err = 0; + struct timeval timeout; + struct sockaddr_nfc_llcp addr; + GIOChannel *channel; + GIOCondition cond; + struct p2p_connect *conn; + + DBG(""); + + fd = socket(AF_NFC, SOCK_STREAM, NFC_SOCKPROTO_LLCP); + if (fd < 0) + return -errno; + + conn = g_try_malloc0(sizeof(struct p2p_connect)); + if (!conn) { + close(fd); + return -ENOMEM; + } + + conn->driver = driver; + conn->ndef = ndef; + conn->cb = cb; + conn->target_idx = target_idx; + conn->adapter_idx = adapter_idx; + + channel = g_io_channel_unix_new(fd); + g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL); + + memset(&addr, 0, sizeof(struct sockaddr_nfc_llcp)); + addr.sa_family = AF_NFC; + addr.dev_idx = adapter_idx; + addr.target_idx = target_idx; + addr.nfc_protocol = NFC_PROTO_NFC_DEP; + addr.service_name_len = strlen(driver->service_name); + strcpy(addr.service_name, driver->service_name); + + timeout.tv_sec = 8; + timeout.tv_usec = 0; + + if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, + sizeof(timeout)) < 0) + near_error("Could not set the receive timeout\n"); + + if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, + sizeof(timeout)) < 0) + near_error("Could not set the send timeout\n"); + + err = connect(fd, (struct sockaddr *) &addr, + sizeof(struct sockaddr_nfc_llcp)); + if (err < 0 && errno != EINPROGRESS) { + near_error("Connect failed %d", errno); + g_free(conn); + close(fd); + + return err; + } + + cond = G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL; + conn->watch = g_io_add_watch(channel, cond, p2p_connect_event, conn); + g_io_channel_unref(channel); + + return fd; +} + +static int p2p_push(uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, char *service_name, + near_device_io_cb cb) +{ + int fd; + GSList *list; + + DBG(""); + + for (list = driver_list; list; list = list->next) { + struct near_p2p_driver *driver = list->data; + + if (strcmp(driver->service_name, service_name) != 0) + continue; + /* + * Because of Android's implementation, we have use SNEP for + * Handover. So, on Handover session, we try to connect to + * the handover service and fallback to SNEP on connect fail. + */ + fd = p2p_connect(adapter_idx, target_idx, ndef, cb, driver); + if (fd > 0) + return fd; + + if (driver->fallback_service_name) + return p2p_push(adapter_idx, target_idx, ndef, + (char *) driver->fallback_service_name, + cb); + else + return -1; + } + + return -1; +} + +static struct near_device_driver p2p_driver = { + .priority = NEAR_DEVICE_PRIORITY_HIGH, + .listen = p2p_listen, + .push = p2p_push, +}; + +int near_p2p_register(struct near_p2p_driver *driver) +{ + struct near_p2p_driver *tmp_driver; + GSList *list = NULL; + + DBG("driver %p name %s service %s", driver, driver->name, + driver->service_name); + + for (list = driver_list; list; list = list->next) { + tmp_driver = list->data; + if (g_strcmp0(tmp_driver->service_name, + driver->service_name) == 0) { + near_error("%s already registered", + driver->service_name); + return -EALREADY; + } + } + + driver_list = g_slist_prepend(driver_list, driver); + return 0; +} + +void near_p2p_unregister(struct near_p2p_driver *driver) +{ + DBG("driver %p name %s", driver, driver->service_name); + + driver_list = g_slist_remove(driver_list, driver); +} + +static int p2p_init(void) +{ + DBG(""); + + phdc_init(); + npp_init(); + snep_init(); + snep_validation_init(); + llcp_validation_init(); + handover_init(); + + return near_device_driver_register(&p2p_driver); +} + +static void p2p_exit(void) +{ + DBG(""); + + g_list_free_full(server_list, free_server_data); + + llcp_validation_exit(); + snep_exit(); + snep_validation_exit(); + npp_exit(); + phdc_exit(); + handover_exit(); + + near_device_driver_unregister(&p2p_driver); +} + +NEAR_PLUGIN_DEFINE(p2p, "NFC Forum peer to peer mode support", VERSION, + NEAR_PLUGIN_PRIORITY_HIGH, p2p_init, p2p_exit)
diff --git a/neard/plugins/p2p.h b/neard/plugins/p2p.h new file mode 100644 index 0000000..a91155f --- /dev/null +++ b/neard/plugins/p2p.h
@@ -0,0 +1,70 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef AF_NFC +#define AF_NFC 39 +#endif + +#ifndef SOL_NFC +#define SOL_NFC 280 +#endif + +#define LLCP_DEFAULT_MIU 128 + +struct near_p2p_driver { + char *name; + char *service_name; + const char *fallback_service_name; + bool single_connection; + int sock_type; + gpointer user_data; + + bool (*read)(int client_fd, uint32_t adapter_idx, uint32_t target_idx, + near_device_io_cb cb, + gpointer data); + int (*push)(int client_fd, uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_device_io_cb cb, + gpointer data); + void (*close)(int client_fd, int err, gpointer data); + bool (*new_client)(char *service_name, int client_fd, gpointer data); +}; + +int phdc_init(void); +void phdc_exit(void); + +int npp_init(void); +void npp_exit(void); + +int handover_init(void); +void handover_exit(void); + +int snep_init(void); +void snep_exit(void); + +int snep_validation_init(void); +void snep_validation_exit(void); + +int llcp_validation_init(void); +void llcp_validation_exit(void); + +int near_p2p_register(struct near_p2p_driver *driver); +void near_p2p_unregister(struct near_p2p_driver *driver);
diff --git a/neard/plugins/phdc.c b/neard/plugins/phdc.c new file mode 100644 index 0000000..5068e65 --- /dev/null +++ b/neard/plugins/phdc.c
@@ -0,0 +1,561 @@ +/* + * neard - Near Field Communication manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <near/nfc_copy.h> +#include <near/dbus.h> +#include <near/log.h> +#include <near/device.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "p2p.h" + + +#define NFC_NEARD_PHDC_IFACE NFC_SERVICE ".PHDC" +#define NFC_NEARD_PHDC_PATH "/" + +/* Phdc Agent */ +#define PHDC_MANAGER_IFACE "org.neard.PHDC.Manager" +#define DEFAULT_PHDC_AGENT_PATH "/" +#define DEFAULT_PHDC_SERVICE "urn:nfc:sn:phdc" + +/* + * Client role + * TODO: Extend the role to Agent + */ +#define ROLE_MANAGER_TEXT "Manager" +#define ROLE_AGENT_TEXT "Agent" + +enum near_role_id { + ROLE_UNKNOWN = 0, + ROLE_MANAGER = 1, + ROLE_AGENT = 2, +}; + +#define AGENT_NEWCONNECTION "NewConnection" +#define AGENT_DISCONNECT "Disconnection" +#define AGENT_RELEASE "Release" + +struct near_phdc_data { + char *sender; /* dbus sender internal */ + enum near_role_id role; /* Manager or Agent */ + char *path; /* dbus manager path */ + struct near_p2p_driver *p2p_driver; /* associated p2p driver */ + guint watch; /* dbus watch */ +}; + +static DBusConnection *phdc_conn; +static GHashTable *mgr_list = NULL; /* Existing managers list */ + +static DBusMessage *error_invalid_arguments(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".InvalidArguments", "Invalid arguments"); +} + +static DBusMessage *error_not_found(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".NotFound", "Not found"); +} + +static DBusMessage *error_permission_denied(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".PermissionDenied", "PermissionDenied"); +} + +static DBusMessage *error_failed(DBusMessage *msg, int errnum) +{ + const char *str = strerror(errnum); + + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".Failed", "%s", str); +} + +/* Search for the specific path */ +static void *search_mgr_list_by_path(const char *path) +{ + struct near_phdc_data *tmp; + GHashTableIter it; + gpointer key; + + DBG("Look for mgr path %s", path); + g_hash_table_iter_init(&it, mgr_list); + while (g_hash_table_iter_next(&it, &key, (gpointer *)&tmp)) + if (g_str_equal(tmp->path, path)) + return (void *)tmp; + return NULL; +} + +/* add the new phdc manager if the associated service is not already there */ +static int manager_add_to_list(struct near_phdc_data *mgr) +{ + DBG(" mgr service name %s", mgr->p2p_driver->service_name); + + if (g_hash_table_lookup(mgr_list, mgr->p2p_driver->service_name)) { + near_error("[%s] already present", + mgr->p2p_driver->service_name); + return -EALREADY; + } + + g_hash_table_insert(mgr_list, mgr->p2p_driver->service_name, mgr); + + return 0; +} + +static void mgr_agent_release(gpointer key, gpointer data, gpointer user_data) +{ + struct near_phdc_data *mgr_data = data; + DBusMessage *message; + + DBG("%s %s", mgr_data->sender, mgr_data->path); + + message = dbus_message_new_method_call(mgr_data->sender, mgr_data->path, + PHDC_MANAGER_IFACE, AGENT_RELEASE); + if (!message) + return; + + dbus_message_set_no_reply(message, TRUE); + + g_dbus_send_message(phdc_conn, message); +} + +static void free_mgr_data(gpointer data) +{ + struct near_phdc_data *mgr_data = data; + + DBG("%p", data); + + /* free memory */ + if (mgr_data->watch > 0) + g_dbus_remove_watch(phdc_conn, mgr_data->watch); + + if (mgr_data->p2p_driver) { + g_free(mgr_data->p2p_driver->name); + g_free(mgr_data->p2p_driver->service_name); + g_free(mgr_data->p2p_driver); + } + + g_free(mgr_data->path); + g_free(mgr_data->sender); + + g_free(mgr_data); +} + +/* + * This function is called when a new client (Phdc Agent) connects on the + * same p2p service as the one we previously registered. We have to find the + * right Phdc Manager (with the service name) to send it the file descriptor. + */ +static bool phdc_p2p_newclient(char *service_name, int agent_fd, gpointer data) +{ + DBusMessage *msg; + DBusMessageIter args; + struct near_phdc_data *mgr; + + DBG(""); + + if ((!agent_fd) || (!service_name)) + return false; + + DBG("service name: %s fd: %d", service_name, agent_fd); + + /* Look for existing service name */ + mgr = g_hash_table_lookup(mgr_list, service_name); + if (!mgr) + return false; + + mgr->p2p_driver->user_data = mgr; + + /* Call the pdhc manager */ + msg = dbus_message_new_method_call(mgr->sender, mgr->path, + PHDC_MANAGER_IFACE, + AGENT_NEWCONNECTION); + if (!msg) { + near_error("msg NULL"); + return false; + } + + /* Add args */ + dbus_message_iter_init_append(msg, &args); + + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UNIX_FD, + &agent_fd)) { + near_error("out of memory"); + return false; + } + + dbus_message_set_no_reply(msg, TRUE); + if (g_dbus_send_message(phdc_conn, msg) == FALSE) { + near_error("Dbus send failed"); + return false; + } + + return true; +} + +static void phdc_p2p_close(int agent_fd, int err, gpointer data) +{ + DBusMessage *msg; + DBusMessageIter args; + struct near_phdc_data *mgr; + + mgr = (struct near_phdc_data *)data; + + DBG("fd: %d err: %d mgr:%p", agent_fd, err, mgr); + if (!mgr) { + near_error("mgr is null"); + return; + } + + msg = dbus_message_new_method_call(mgr->sender, mgr->path, + PHDC_MANAGER_IFACE, + AGENT_DISCONNECT); + if (!msg) { + near_error("msg NULL"); + return; + } + + dbus_message_iter_init_append(msg, &args); + + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UNIX_FD, + &agent_fd)) { + near_error("out of memory"); + return; + } + + dbus_message_iter_init_append(msg, &args); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &err)) { + near_error("out of memory"); + return; + } + + dbus_message_set_no_reply(msg, TRUE); + + if (g_dbus_send_message(phdc_conn, msg) == FALSE) + near_error("Dbus send failed"); +} + +/* Called when the external Phdc manager ends or disconnect */ +static void phdc_manager_disconnect(DBusConnection *conn, void *user_data) +{ + struct near_phdc_data *phdc_mgr = user_data; + + phdc_mgr->watch = 0; + + DBG("PHDC manager %s disconnected", phdc_mgr->sender); + /* Stop the associated p2p driver */ + near_p2p_unregister(phdc_mgr->p2p_driver); + + g_hash_table_remove(mgr_list, phdc_mgr->p2p_driver->service_name); +} + +/* + * Parse the data dictionary sent, to fill the phdc_mgr and p2p driver struct. + */ +static int parse_dictionary(DBusMessage *msg, void *data, + struct near_phdc_data *phdc_mgr, + struct near_p2p_driver *p2p) +{ + DBusMessageIter array, dict; + int err; + + /* p2p should exist */ + if (!p2p) + return -EINVAL; + + if (dbus_message_iter_init(msg, &array) == FALSE) + return -EINVAL; + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY) + return -EINVAL; + + dbus_message_iter_recurse(&array, &dict); + + err = -ENOMEM; + while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter entry, value; + const char *key; + + dbus_message_iter_recurse(&dict, &entry); + dbus_message_iter_get_basic(&entry, &key); + + dbus_message_iter_next(&entry); + dbus_message_iter_recurse(&entry, &value); + + /* get p2p driver service name */ + if (g_str_equal(key, "ServiceName")) { + dbus_message_iter_get_basic(&value, &data); + g_free(p2p->service_name); + + p2p->service_name = g_strdup(data); + if (!p2p->service_name) + goto error; + } + + if (g_str_equal(key, "Path")) { + dbus_message_iter_get_basic(&value, &data); + g_free(phdc_mgr->path); + phdc_mgr->path = g_strdup(data); + if (!phdc_mgr->path) + goto error; + } else if (g_str_equal(key, "Role")) { + dbus_message_iter_get_basic(&value, &data); + /* Manager or Agent only */ + if (g_strcmp0(data, ROLE_MANAGER_TEXT) == 0) + phdc_mgr->role = ROLE_MANAGER; + else if (g_strcmp0(data, ROLE_AGENT_TEXT) == 0) + phdc_mgr->role = ROLE_AGENT; + else { + err = -EINVAL; + goto error; + } + } + + dbus_message_iter_next(&dict); + } + + return 0; + +error: + g_free(p2p->service_name); + p2p->service_name = NULL; + + + g_free(phdc_mgr->path); + phdc_mgr->path = NULL; + + return err; +} + +/* + * A Phdc Manager requests to be added to the manager list. + * - parse the parameters + * + * Initial version: the PHDC manager calls dbus_register_phdc_manager, + * sending a simple path and a service name + * TODO: check for DBUS_TYPE_UNIX_FD ((int) 'h') + */ +static DBusMessage *dbus_register_phdc_agent(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct near_phdc_data *phdc_mgr; + int err; + + DBG("conn %p", conn); + + /* Allocate the phdc_mgr struct */ + phdc_mgr = g_try_malloc0(sizeof(struct near_phdc_data)); + if (!phdc_mgr) { + err = -ENOMEM; + goto error; + } + + /* Allocate a default p2p_driver */ + phdc_mgr->p2p_driver = g_try_malloc0(sizeof(struct near_p2p_driver)); + if (!phdc_mgr->p2p_driver) { + err = -ENOMEM; + goto error; + } + + /* Get the the sender name */ + phdc_mgr->sender = g_strdup(dbus_message_get_sender(msg)); + + DBG("%s", phdc_mgr->sender); + + /* default p2p values */ + phdc_mgr->p2p_driver->fallback_service_name = NULL; + phdc_mgr->p2p_driver->sock_type = SOCK_STREAM; + phdc_mgr->p2p_driver->single_connection = FALSE; + phdc_mgr->p2p_driver->new_client = phdc_p2p_newclient; + phdc_mgr->p2p_driver->close = phdc_p2p_close; + + /* look for dict values and fill the struct */ + err = parse_dictionary(msg, data, phdc_mgr, phdc_mgr->p2p_driver); + if (err < 0) + goto error; + + /* TODO: At this time, there's no support for Role == Agent */ + if (phdc_mgr->role == ROLE_AGENT) { + err = -ENOTSUP; + goto error; + } + + /* No correct role ? */ + if (phdc_mgr->role == ROLE_UNKNOWN) { + err = -EINVAL; + goto error; + } + + /* No path ? */ + if (!phdc_mgr->path) { + err = -EINVAL; + goto error; + } + + /* defaulting the p2p driver */ + if (!phdc_mgr->p2p_driver->service_name) + phdc_mgr->p2p_driver->service_name = + g_strdup(DEFAULT_PHDC_SERVICE); + + /* p2p internal name */ + phdc_mgr->p2p_driver->name = g_strdup_printf("{%s-%s}", + (phdc_mgr->role == ROLE_MANAGER ? ROLE_MANAGER_TEXT : + ROLE_AGENT_TEXT), + phdc_mgr->p2p_driver->service_name); + + /* if one pointer is null, memory failed ! */ + if ((!phdc_mgr->p2p_driver->name) || + (!phdc_mgr->p2p_driver->service_name)) { + err = -ENOMEM; + goto error; + } + + /* Watch the Phdc Manager */ + phdc_mgr->watch = g_dbus_add_disconnect_watch(phdc_conn, + phdc_mgr->sender, + phdc_manager_disconnect, + phdc_mgr, NULL); + /* Add to the existing Manager list */ + err = manager_add_to_list(phdc_mgr); + if (err < 0) + goto error; + + /* and register the p2p driver for the specified service */ + err = near_p2p_register(phdc_mgr->p2p_driver); + if (err < 0) + goto error; + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); + +error: + /* free memory */ + if (phdc_mgr) + free_mgr_data(phdc_mgr); + + return error_failed(msg, -err); +} + +/* + * Phdc Manager requests to be removed from the existing list of managers. + */ +static DBusMessage *dbus_unregister_phdc_agent(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct near_phdc_data *mgr; + DBusMessageIter iter; + const char *path, *role, *sender; + + DBG("conn %p", conn); + + if (!dbus_message_iter_init(msg, &iter)) + return error_invalid_arguments(msg); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH) + return error_invalid_arguments(msg); + + sender = dbus_message_get_sender(msg); + + dbus_message_iter_get_basic(&iter, &path); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + return error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &role); + + /* look for specific path */ + mgr = search_mgr_list_by_path(path); + if (!mgr) + return error_not_found(msg); + + DBG("%s", mgr->sender); + + if (strncmp(sender, mgr->sender, strlen(mgr->sender))) + return error_permission_denied(msg); + + /* remove it */ + near_p2p_unregister(mgr->p2p_driver); + + g_hash_table_remove(mgr_list, mgr->p2p_driver->service_name); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static const GDBusMethodTable phdc_methods[] = { + { GDBUS_METHOD("RegisterAgent", + GDBUS_ARGS({"", "a{sv}"}), + NULL, dbus_register_phdc_agent) }, + +{ GDBUS_METHOD("UnregisterAgent", + GDBUS_ARGS({ "path", "o" }, { "type", "s"}), + NULL, dbus_unregister_phdc_agent) }, + { }, +}; + +/* Initialize the PHDC plugin - Expose our dbus entry points */ +int phdc_init(void) +{ + gboolean err; + + DBG(""); + + /* save the dbus connection */ + phdc_conn = near_dbus_get_connection(); + + mgr_list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, + free_mgr_data); + + /* register dbus interface */ + err = g_dbus_register_interface(phdc_conn, "/org/neard", + NFC_NEARD_PHDC_IFACE, + phdc_methods, + NULL, NULL, NULL, NULL); + + return err; +} + +/* Called when exiting neard */ +void phdc_exit(void) +{ + DBG(""); + + /* Notify listeners...*/ + g_hash_table_foreach(mgr_list, mgr_agent_release, NULL); + + g_dbus_unregister_interface(phdc_conn, "/org/neard", + NFC_NEARD_PHDC_IFACE); + /* Clean before leaving */ + g_hash_table_remove_all(mgr_list); + g_hash_table_destroy(mgr_list); +}
diff --git a/neard/plugins/snep-validation.c b/neard/plugins/snep-validation.c new file mode 100644 index 0000000..2261938 --- /dev/null +++ b/neard/plugins/snep-validation.c
@@ -0,0 +1,262 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/device.h> +#include <near/ndef.h> +#include <near/tlv.h> +#include <near/snep.h> + +#include "p2p.h" + +/* Would store incoming ndefs per client */ +static GHashTable *snep_validation_hash = NULL; + +/* Callback: free validation data */ +static void free_snep_validation_client(gpointer data) +{ + GList *old_ndefs = data; + + if (old_ndefs) + g_list_free(old_ndefs); +} + +/* Validation Server REQ_PUT function + * The validation server shall accept PUT and GET requests. A PUT request shall + * cause the server to store the ndef message transmitted with the request. + * */ +static bool snep_validation_server_req_put(int client_fd, void *data) +{ + struct p2p_snep_data *snep_data = data; + GList *records; + struct near_ndef_record *recd; + GList *incoming_ndefs; + + DBG(""); + + if (!snep_data->nfc_data) + goto error; + + /* + * We received a ndef, parse it, check if there's only + * 1 record (a mime type !) with an ID + */ + records = near_ndef_parse_msg(snep_data->nfc_data, + snep_data->nfc_data_length, NULL); + + if (g_list_length(records) != 1) { + DBG("records number mismatch"); + goto error; + } + + recd = records->data; + + if (!recd) { + g_list_free(records); + goto error; + } + + /* Save the record but look if there are some incoming ndef stored */ + incoming_ndefs = g_hash_table_lookup(snep_validation_hash, + GINT_TO_POINTER(client_fd)); + + incoming_ndefs = g_list_append(incoming_ndefs, recd); + + /* remove existing one silently */ + g_hash_table_steal(snep_validation_hash, GINT_TO_POINTER(client_fd)); + /* push the new one */ + g_hash_table_insert(snep_validation_hash, GINT_TO_POINTER(client_fd), + incoming_ndefs); + + + near_snep_core_response_noinfo(client_fd, NEAR_SNEP_RESP_SUCCESS); + + return true; + +error: + near_snep_core_response_noinfo(client_fd, NEAR_SNEP_RESP_REJECT); + + return true; +} + +/* + * Validation Server REQ_GET function + * The validation server shall accept PUT and GET requests. A GET request shall + * cause the server to return a previously stored NDEF message of the same NDEF + * message type and identifier as transmitted with the request. + * */ +static bool snep_validation_server_req_get(int client_fd, void *data) +{ + struct p2p_snep_data *snep_data = data; + struct near_ndef_record *recd, *rec_store; + uint32_t acceptable_length; + GList *records; + GList *iter; + GList *incoming_ndefs; + + DBG(""); + + /* + * We received a ndef, parse it, check if there's only + * 1 record (a mime type !) with an ID + */ + records = near_ndef_parse_msg(snep_data->nfc_data + + NEAR_SNEP_ACC_LENGTH_SIZE, + snep_data->nfc_data_length - NEAR_SNEP_ACC_LENGTH_SIZE, + NULL); + + if (g_list_length(records) != 1) { + DBG("records number mismatch"); + goto error; + } + + recd = records->data; + if (!recd) { + g_list_free(records); + goto error; + } + + /* check if the acceptable length is higher than the data_len + * otherwise returns a NEAR_SNEP_RESP_EXCESS + */ + acceptable_length = near_get_be32(snep_data->nfc_data); + + /* Look if there are some incoming ndef stored */ + incoming_ndefs = g_hash_table_lookup(snep_validation_hash, + GINT_TO_POINTER(client_fd)); + + if (!incoming_ndefs) + goto done; + + /* Now, loop to find the the associated record */ + for (iter = incoming_ndefs; iter; iter = iter->next) { + + rec_store = iter->data; + /* Same mime type and same id ?*/ + + if (!near_ndef_record_cmp_id(recd, rec_store)) + continue; + + if (!near_ndef_record_cmp_mime(recd, rec_store)) + continue; + + /* Found a record, check the length */ + if (acceptable_length >= near_ndef_data_length(rec_store)) { + near_snep_core_response_with_info(client_fd, + NEAR_SNEP_RESP_SUCCESS, + near_ndef_data_ptr(rec_store), + near_ndef_data_length(rec_store)); + + incoming_ndefs = g_list_remove(incoming_ndefs, + iter->data); + /* remove existing one silently */ + g_hash_table_steal(snep_validation_hash, + GINT_TO_POINTER(client_fd)); + /* push the new one */ + g_hash_table_insert(snep_validation_hash, + GINT_TO_POINTER(client_fd), + incoming_ndefs); + + } else + near_snep_core_response_noinfo(client_fd, NEAR_SNEP_RESP_EXCESS); + + return true; + } + +done: + /* If not found */ + near_snep_core_response_noinfo(client_fd, NEAR_SNEP_RESP_NOT_FOUND); + return true; + +error: + /* Not found */ + near_snep_core_response_noinfo(client_fd, NEAR_SNEP_RESP_REJECT); + return false; +} + +/* This function is a wrapper to push post processing read functions */ +static bool snep_validation_read(int client_fd, uint32_t adapter_idx, + uint32_t target_idx, + near_tag_io_cb cb, + gpointer data) +{ + DBG(""); + + return near_snep_core_read(client_fd, adapter_idx, target_idx, cb, + snep_validation_server_req_get, + snep_validation_server_req_put, + data); + +} + +static void snep_validation_close(int client_fd, int err, gpointer data) +{ + DBG(""); + + g_hash_table_remove(snep_validation_hash, GINT_TO_POINTER(client_fd)); + + /* Call core server close */ + near_snep_core_close(client_fd, err, data); +} + +struct near_p2p_driver validation_snep_driver = { + .name = "VALIDATION_SNEP", + .service_name = "urn:nfc:xsn:nfc-forum.org:snep-validation", + .fallback_service_name = NULL, + .sock_type = SOCK_STREAM, + .read = snep_validation_read, + .push = near_snep_core_push, + .close = snep_validation_close, +}; + +int snep_validation_init(void) +{ + /* Would store incoming ndefs per client */ + snep_validation_hash = g_hash_table_new_full(g_direct_hash, + g_direct_equal, NULL, + free_snep_validation_client); + + return near_p2p_register(&validation_snep_driver); +} + +void snep_validation_exit(void) +{ + near_p2p_unregister(&validation_snep_driver); + + g_hash_table_destroy(snep_validation_hash); + snep_validation_hash = NULL; +}
diff --git a/neard/plugins/snep.c b/neard/plugins/snep.c new file mode 100644 index 0000000..7557f78 --- /dev/null +++ b/neard/plugins/snep.c
@@ -0,0 +1,150 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/log.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/device.h> +#include <near/ndef.h> +#include <near/tlv.h> +#include <near/snep.h> + +#include "p2p.h" + +/* + * This is the Default server REQ PUT function. + * On REQ PUT, server should store the associated ndef as a record. + * + * TODO: check the nfc_data (simple NDEF or complete frame ?) + * */ +static bool snep_default_server_req_put(int client_fd, void *data) +{ + struct p2p_snep_data *snep_data = data; + struct near_device *device; + GList *records; + + DBG(""); + + /* The request is ok, so we notify the client */ + near_snep_core_response_noinfo(client_fd, NEAR_SNEP_RESP_SUCCESS); + + /* On PUT request, we add the data */ + if (near_device_add_data(snep_data->adapter_idx, + snep_data->target_idx, + snep_data->nfc_data, + snep_data->nfc_data_length) < 0) + return false; + + device = near_device_get_device(snep_data->adapter_idx, + snep_data->target_idx); + if (!device) + return false; + + records = near_ndef_parse_msg(snep_data->nfc_data, + snep_data->nfc_data_length, NULL); + + near_device_add_records(device, records, snep_data->cb, 0); + + snep_data->nfc_data_length = 0; + snep_data->nfc_data = NULL; + + return true; +} + +/* + * This is the Default server REQ GET function. + * On REQ GET, server should return NEAR_SNEP_RESP_NOT_IMPL. + * + * !!! We check if the incoming NDEF looks like a handover frame, + * because of Android 4.1.1 ... + * */ +static bool snep_default_server_req_get(int client_fd, void *data) +{ + struct p2p_snep_data *snep_data = data; + + DBG(""); + + /* + * Check if this is a handover request or not ... + * snep_data->nfc_data points to the acceptable length field (4 bytes) + * and we check the 3 byte in the NDEF message + * */ + + if (*(snep_data->nfc_data + NEAR_SNEP_REQ_ANDROID) != 'H') { + near_snep_core_response_noinfo(client_fd, NEAR_SNEP_RESP_NOT_IMPL); + } else { + near_snep_core_parse_handover_record(client_fd, snep_data->nfc_data + + NEAR_SNEP_ACC_LENGTH_SIZE, + snep_data->nfc_data_length - + NEAR_SNEP_ACC_LENGTH_SIZE); + } + + return true; +} + +/* This function is a wrapper to push post processing read functions */ +static bool snep_default_read(int client_fd, uint32_t adapter_idx, + uint32_t target_idx, + near_tag_io_cb cb, + gpointer data) +{ + DBG(""); + + return near_snep_core_read(client_fd, adapter_idx, target_idx, cb, + snep_default_server_req_get, + snep_default_server_req_put, + data); + +} + +struct near_p2p_driver snep_driver = { + .name = "SNEP", + .service_name = NEAR_DEVICE_SN_SNEP, + .fallback_service_name = NEAR_DEVICE_SN_NPP, + .sock_type = SOCK_STREAM, + .read = snep_default_read, + .push = near_snep_core_push, + .close = near_snep_core_close, +}; + +int snep_init(void) +{ + return near_p2p_register(&snep_driver); +} + +void snep_exit(void) +{ + near_p2p_unregister(&snep_driver); +}
diff --git a/neard/se/TODO b/neard/se/TODO new file mode 100644 index 0000000..122adfe --- /dev/null +++ b/neard/se/TODO
@@ -0,0 +1,9 @@ +Background +========== + +- Priority scale: High, Medium and Low + +- Complexity scale: C1, C2, C4 and C8. + The complexity scale is exponential, with complexity 1 being the + lowest complexity. Complexity is a function of both task 'complexity' + and task 'scope'.
diff --git a/neard/se/ace.c b/neard/se/ace.c new file mode 100644 index 0000000..8033029 --- /dev/null +++ b/neard/se/ace.c
@@ -0,0 +1,879 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <errno.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "driver.h" +#include "seel.h" + +#define MAX_AID_LEN 16 +#define MIN_AID_LEN 5 + +#define APP_HASH_LEN 20 + +#define GP_AID_LEN 9 +uint8_t gp_aid[] = {0xA0, 0x00, 0x00, 0x01, + 0x51, 0x41, 0x43, 0x4C, 0x00 }; + +/* Data Object Tags */ +#define AID_REF_DO_ALL 0xC0 +#define HASH_REF_DO 0xC1 +#define AID_REF_DO 0x4F +#define REF_DO 0xE1 +#define REF_AR_DO 0xE2 +#define AR_DO 0xE3 +#define APDU_AR_DO 0xD0 +#define NFC_AR_DO 0xD1 + +#define APDU_STATUS_LEN 2 +#define GET_ALL_DATA_CMD_LEN 2 +#define GET_REFRESH_DATA_CMD_LEN 2 +#define GET_REFRESH_DATA_TAG_LEN 1 +#define GET_REFRESH_TAG_LEN 8 + +/* if ((APDU_header & rule->mask) == rule->header) then APDU is allowed */ +struct seel_ace_apdu_rule { + uint32_t header; + uint32_t mask; +}; + +struct seel_ace_rule { + uint8_t aid[MAX_AID_LEN]; + size_t aid_len; + + uint8_t hash[APP_HASH_LEN]; + size_t hash_len; + + uint8_t *apdu_rules; + size_t apdu_rules_len; + + bool nfc_rule; +}; + +struct seel_ace { + struct seel_se *se; + + size_t rules_length; + size_t current_rules_length; + uint8_t *rules_payload; + + uint8_t rules_tag[8]; + + GSList *rules; +}; + +GHashTable *ace_hash; + +static void free_rule(gpointer data) +{ + struct seel_ace_rule *rule = data; + + DBG("%p", rule); + + g_free(rule->apdu_rules); + g_free(rule); +} + +static void free_ace(gpointer data) +{ + struct seel_ace *ace = data; + + DBG("%p %p", ace, ace->rules); + + g_slist_free_full(ace->rules, free_rule); + g_free(ace); +} + +static void dump_rule(gpointer data, gpointer user_data) +{ + struct seel_ace_rule *rule = data; + struct seel_ace_apdu_rule *apdu_rule; + char aid[3 * MAX_AID_LEN + 1]; + char hash[3 * APP_HASH_LEN + 1]; + size_t i; + + DBG("ACE Rule:"); + + if (rule->aid_len == 0) { + DBG(" Hash: All SE applications"); + } else { + for (i = 0; i < rule->aid_len; i++) + sprintf(aid + (3 * i), "%02X ", rule->aid[i]); + aid[3 * i] = 0; + DBG(" AID [%zd]: %s", rule->aid_len, aid); + } + + if (rule->hash_len == 0) { + DBG(" Hash: All host applications"); + } else { + for (i = 0; i < rule->hash_len; i++) + sprintf(hash + (3 * i), "%02X ", rule->hash[i]); + hash[3 * i] = 0; + DBG(" Hash [%zd]: %s", rule->hash_len, hash); + } + + if (rule->apdu_rules_len == 1) { + DBG(" APDU: %s", rule->apdu_rules[0] ? "Always" : "Never"); + } else { + uint8_t *header, *mask; + size_t n_rules; + + apdu_rule = (struct seel_ace_apdu_rule *)rule->apdu_rules; + n_rules = rule->apdu_rules_len / + sizeof(struct seel_ace_apdu_rule); + + DBG(" APDU rules (%zd)", n_rules); + for (i = 0; i < n_rules; i++) { + header = (uint8_t *)&apdu_rule->header; + mask = (uint8_t *)&apdu_rule->mask; + DBG(" header 0x%02x:0x%02x:0x%02x:0x%02x " + "mask 0x%02x:0x%02x:0x%02x:0x%02x", + header[0], header[1], header[2], header[3], + mask[0], mask[1], mask[2], mask[3]); + apdu_rule++; + } + } + + DBG(" NFC: %s", rule->nfc_rule ? "Always" : "Never"); + +} + +static void dump_ace(struct seel_ace *ace) +{ + DBG("ACE Tag [0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x]", + ace->rules_tag[0], ace->rules_tag[1], ace->rules_tag[2], ace->rules_tag[3], + ace->rules_tag[4], ace->rules_tag[5], ace->rules_tag[6], ace->rules_tag[7]); + + g_slist_foreach(ace->rules, dump_rule, NULL); +} + +static int build_ref(struct seel_ace_rule *ace_rule, + uint8_t *rule, size_t rule_length) +{ + uint8_t *rule_ptr; + size_t remaining, do_length; + + remaining = rule_length; + rule_ptr = rule; + while (remaining) { + + switch (rule_ptr[0]) { + case AID_REF_DO: + do_length = rule_ptr[1]; + DBG("AID_REF_DO %zd", do_length); + rule_ptr += 2; + + if (remaining < do_length) + return -EINVAL; + + if (do_length > MAX_AID_LEN) + return -EINVAL; + + memcpy(ace_rule->aid, rule_ptr, do_length); + ace_rule->aid_len = do_length; + + remaining -= do_length + 2; + rule_ptr += do_length; + + break; + + case HASH_REF_DO: + do_length = rule_ptr[1]; + DBG("HASH_REF_DO %zd", do_length); + rule_ptr += 2; + + if (remaining < do_length) + return -EINVAL; + + if (do_length > APP_HASH_LEN) + return -EINVAL; + + memcpy(ace_rule->hash, rule_ptr, do_length); + ace_rule->hash_len = do_length; + + remaining -= do_length + 2; + rule_ptr += do_length; + + break; + + default: + return -EINVAL; + } + } + + return 0; +} + +static int build_ar(struct seel_ace_rule *ace_rule, + uint8_t *rule, size_t rule_length) +{ + uint8_t *rule_ptr; + size_t remaining, do_length; + + remaining = rule_length; + rule_ptr = rule; + while (remaining) { + + switch (rule_ptr[0]) { + case APDU_AR_DO: + do_length = rule_ptr[1]; + DBG("APDU_AR_DO %zd", do_length); + rule_ptr += 2; + + if (remaining < do_length) + return -EINVAL; + + ace_rule->apdu_rules = g_try_malloc0(do_length); + if (!ace_rule->apdu_rules) + return -ENOMEM; + + memcpy(ace_rule->apdu_rules, rule_ptr, do_length); + ace_rule->apdu_rules_len = do_length; + + remaining -= do_length + 2; + rule_ptr += do_length; + + break; + + case NFC_AR_DO: + do_length = rule_ptr[1]; + DBG("NFC_AR_DO %zd", do_length); + rule_ptr += 2; + + if (do_length != 1) + return -EINVAL; + + ace_rule->nfc_rule = !!rule_ptr[0]; + + remaining -= do_length + 2; + rule_ptr += do_length; + + break; + + default: + return -EINVAL; + } + } + + return 0; +} + +static struct seel_ace_rule *build_rule(struct seel_ace *ace, + uint8_t *rule, size_t rule_length) +{ + struct seel_ace_rule *ace_rule; + uint8_t *rule_ptr; + size_t remaining, do_length; + int err; + + DBG(""); + + ace_rule = g_try_malloc0(sizeof(struct seel_ace_rule)); + if (!ace_rule) + return NULL; + + remaining = rule_length; + rule_ptr = rule; + while (remaining) { + + switch (rule_ptr[0]) { + case REF_DO: + do_length = rule_ptr[1]; + DBG("REF_DO %zd", do_length); + rule_ptr += 2; + + err = build_ref(ace_rule, rule_ptr, do_length); + if (err) + goto error; + + remaining -= do_length + 2; + rule_ptr += do_length; + + break; + + case AR_DO: + do_length = rule_ptr[1]; + DBG("AR_DO %zd", do_length); + rule_ptr += 2; + + err = build_ar(ace_rule, rule_ptr, do_length); + if (err) + goto error; + + remaining -= do_length + 2; + rule_ptr += do_length; + + break; + default: + goto error; + } + } + + return ace_rule; + +error: + free_rule(ace_rule); + return NULL; +} + +static int build_ace_rules(struct seel_ace *ace, + uint8_t *rules, size_t rules_length) +{ + struct seel_ace_rule *rule; + uint8_t *rule_ptr; + size_t remaining = rules_length, ref_ar_do_length; + int err; + + DBG(""); + + err = 0; + remaining = rules_length; + rule_ptr = rules; + while (remaining) { + if (rule_ptr[0] != REF_AR_DO) { + rule_ptr++; + remaining--; + continue; + } + + ref_ar_do_length = rule_ptr[1]; + /* Tag + Length + value length */ + remaining -= ref_ar_do_length + 2; + rule_ptr += 2; + + DBG("REF_AR_DO %zd bytes", ref_ar_do_length); + + rule = build_rule(ace, rule_ptr, ref_ar_do_length); + if (!rule) { + err = -EINVAL; + break; + } + + ace->rules = g_slist_append(ace->rules, rule); + + rule_ptr += ref_ar_do_length; + } + + return err; +} + +static int ace_rule_length(uint8_t *apdu, size_t apdu_length, + size_t *length_length) +{ + size_t length; + + if (apdu_length < 3) + return -EINVAL; + + length = apdu[2]; + *length_length = 1; + + /* + * BER: If length bit 8 is one, bit [0..7] is the number + * of bytes used for encoding the length. + */ + if (length & 0x80) { + size_t _length = length & 0x7f, i, base; + + DBG("%zd", _length); + + if (apdu_length < 3 + _length) + return -EINVAL; + + length = 0; + base = 1 << 8 * _length; + for (i = 0; i < _length; i++) { + base >>= 8; + length += apdu[3 + i] * base; + } + + *length_length = _length + 1; + } + + DBG("length 0x%zx", length); + + return length; +} + +static void get_next_gp_data(struct seel_ace *ace); + +static void get_next_gp_data_cb(void *context, + uint8_t *apdu, size_t apdu_length, + int err) +{ + struct seel_ace *ace = context; + size_t payload_length; + + DBG("Current %zd Total %zd Got %zd", + ace->current_rules_length, ace->rules_length, apdu_length); + + if (err) + goto out; + + payload_length = apdu_length - APDU_STATUS_LEN; + + if (ace->current_rules_length + payload_length > ace->rules_length) + goto out; + + memcpy(ace->rules_payload + ace->current_rules_length, + apdu, payload_length); + ace->current_rules_length += apdu_length - APDU_STATUS_LEN; + + if (ace->current_rules_length < ace->rules_length) + return get_next_gp_data(ace); + + if (build_ace_rules(ace, ace->rules_payload, ace->rules_length)) + goto out; + + dump_ace(ace); + + g_hash_table_replace(ace_hash, ace->se, ace); + +out: + g_free(ace->rules_payload); + + return; +} + +static void get_next_gp_data(struct seel_ace *ace) +{ + struct seel_apdu *get_next_gp_data; + size_t req_length; + int err; + + if (ace->rules_length - ace->current_rules_length < 0x100) + req_length = ace->rules_length - ace->current_rules_length; + else + req_length = 0; + + get_next_gp_data = __seel_apdu_get_next_gp_data(req_length); + if (!get_next_gp_data) { + g_free(ace->rules_payload); + return; + } + + err = __seel_se_queue_io(ace->se, get_next_gp_data, + get_next_gp_data_cb, ace); + if (err < 0) { + near_error("GET NEXT ALL err %d", err); + return; + } + + return; +} + +static void get_all_gp_data_cb(void *context, + uint8_t *apdu, size_t apdu_length, + int err) +{ + struct seel_ace *ace = context; + size_t length_length, payload_length; + int rule_length; + + DBG(""); + + if (err) + return; + + rule_length = ace_rule_length(apdu, apdu_length, &length_length); + if (rule_length < 0) + return; + + if (apdu_length > GET_ALL_DATA_CMD_LEN + length_length + + rule_length + APDU_STATUS_LEN) + return; + + payload_length = apdu_length - GET_ALL_DATA_CMD_LEN - + length_length - APDU_STATUS_LEN; + + DBG("Received %zd bytes of payload", payload_length); + + if (payload_length < (size_t)rule_length) { + ace->rules_length = rule_length; + ace->current_rules_length = payload_length; + ace->rules_payload = g_try_malloc0(rule_length); + if (!ace->rules_payload) + return; + + memcpy(ace->rules_payload, + apdu + GET_ALL_DATA_CMD_LEN + length_length, + payload_length); + + return get_next_gp_data(ace); + } + + if (build_ace_rules(ace, apdu + GET_ALL_DATA_CMD_LEN + length_length, + payload_length)) + return; + + dump_ace(ace); + + g_hash_table_replace(ace_hash, ace->se, ace); + + return; +} + +static void get_refresh_gp_data_cb(void *context, + uint8_t *apdu, size_t apdu_length, + int err) +{ + struct seel_se *se = context; + struct seel_ace *ace; + struct seel_apdu *get_all_gp_data; + + DBG(""); + + if (err) + return; + + if (apdu_length != GET_REFRESH_DATA_CMD_LEN + GET_REFRESH_DATA_TAG_LEN + + GET_REFRESH_TAG_LEN + APDU_STATUS_LEN) + return; + + if (apdu[0] != 0xDF || apdu[1] != 0x20 || apdu[2] != 0x08) + return; + + ace = g_try_malloc0(sizeof(struct seel_ace)); + if (!ace) + return; + + ace->se = se; + + memcpy(ace->rules_tag, apdu + GET_REFRESH_DATA_CMD_LEN + + GET_REFRESH_DATA_TAG_LEN, GET_REFRESH_TAG_LEN); + + get_all_gp_data = __seel_apdu_get_all_gp_data(); + if (!get_all_gp_data) + return; + + err = __seel_se_queue_io(se, get_all_gp_data, get_all_gp_data_cb, ace); + if (err < 0) { + near_error("GET DATA ALL err %d", err); + return; + } + + return ; +} + +static void select_gp_aid_cb(void *context, + uint8_t *apdu, size_t apdu_length, + int err) +{ + struct seel_se *se = context; + struct seel_apdu *get_refresh_gp_data; + + DBG(""); + + if (err) + return; + + get_refresh_gp_data = __seel_apdu_get_refresh_gp_data(); + if (!get_refresh_gp_data) + return; + + err = __seel_se_queue_io(se, get_refresh_gp_data, get_refresh_gp_data_cb, se); + if (err < 0) { + near_error("GET REFRESH DATA err %d", err); + return; + } + + return ; +} + +gboolean __seel_ace_add(gpointer user_data) +{ + struct seel_se *se = user_data; + struct seel_apdu *select_gp_aid; + int err; + + DBG(""); + + select_gp_aid = __seel_apdu_select_aid(0, gp_aid, GP_AID_LEN); + if (!select_gp_aid) + return FALSE; + + /* Send the GP AID selection APDU */ + err = __seel_se_queue_io(se, select_gp_aid, select_gp_aid_cb, se); + if (err < 0) { + near_error("GP AID err %d", err); + return FALSE; + } + + return FALSE; +} + +int __seel_ace_remove(struct seel_se *se) +{ + DBG("%p", se); + + if (!g_hash_table_remove(ace_hash, se)) + return -ENODEV; + + return 0; +} + +static struct seel_ace_rule *find_specific_rule(struct seel_ace *ace, + uint8_t *aid, size_t aid_len, + uint8_t *hash) +{ + GSList *list; + + DBG("%zd", aid_len); + + if (!hash || !aid) + return false; + + for (list = ace->rules; list; list = list->next) { + struct seel_ace_rule *rule = list->data; + + if (rule->aid_len != aid_len) + continue; + + if (rule->hash_len != APP_HASH_LEN) + continue; + + if (!memcmp(rule->aid, aid, aid_len) && + !memcmp(rule->hash, hash, APP_HASH_LEN)) { + dump_rule(rule, NULL); + return rule; + } + } + + return NULL; +} + +static bool find_specific_rule_for_aid(struct seel_ace *ace, + uint8_t *aid, size_t aid_len) +{ + GSList *list; + + DBG("%zd", aid_len); + + if (!aid) + return false; + + for (list = ace->rules; list; list = list->next) { + struct seel_ace_rule *rule = list->data; + + if (rule->aid_len != aid_len) + continue; + + if (rule->hash_len != APP_HASH_LEN) + continue; + + if (!memcmp(rule->aid, aid, aid_len)) { + dump_rule(rule, NULL); + return true; + } + } + + return false; +} + +static struct seel_ace_rule *find_generic_rule_for_aid(struct seel_ace *ace, + uint8_t *aid, size_t aid_len) + +{ + GSList *list; + + DBG("%zd", aid_len); + + if (!aid) + return false; + + for (list = ace->rules; list; list = list->next) { + struct seel_ace_rule *rule = list->data; + + if (rule->aid_len != aid_len) + continue; + + /* This is a specific rule */ + if (rule->hash_len) + continue; + + if (!memcmp(rule->aid, aid, aid_len)) { + dump_rule(rule, NULL); + return rule; + } + } + + return NULL; +} + +static struct seel_ace_rule *find_generic_rule_for_hash(struct seel_ace *ace, + uint8_t *hash) +{ + GSList *list; + + DBG(""); + + if (!hash) + return false; + + for (list = ace->rules; list; list = list->next) { + struct seel_ace_rule *rule = list->data; + + /* This is a generic hash rule */ + if (rule->hash_len != APP_HASH_LEN) + continue; + + /* This is a specific AID rule */ + if (rule->aid_len) + continue; + + if (!memcmp(rule->hash, hash, APP_HASH_LEN)) { + dump_rule(rule, NULL); + return rule; + } + } + + return NULL; +} + +static struct seel_ace_rule *find_generic_rule(struct seel_ace *ace) +{ + GSList *list; + + DBG(""); + + for (list = ace->rules; list; list = list->next) { + struct seel_ace_rule *rule = list->data; + + if (rule->hash_len || rule->aid_len) + continue; + + dump_rule(rule, NULL); + return rule; + } + + return NULL; +} + +static bool apdu_allowed(struct seel_ace_rule *rule, + uint8_t *apdu, size_t apdu_len) +{ + size_t i, n_rules; + uint32_t apdu_header; + struct seel_ace_apdu_rule *apdu_rule; + + if (rule->apdu_rules_len == 1) + return rule->apdu_rules[0] ? true : false; + + n_rules = rule->apdu_rules_len / + sizeof(struct seel_ace_apdu_rule); + apdu_header = *((uint32_t *) apdu); + apdu_rule = (struct seel_ace_apdu_rule *)rule->apdu_rules; + + for (i = 0; i < n_rules; i++) { + if ((apdu_header & apdu_rule->mask) == apdu_rule->header) + return true; + + apdu_rule++; + } + + return false; +} + +bool __seel_ace_apdu_allowed(struct seel_channel *channel, uint8_t *hash, + uint8_t *apdu, size_t apdu_len) +{ + struct seel_se *se; + struct seel_ace *ace; + struct seel_ace_rule *rule; + uint8_t *aid; + size_t aid_len; + + DBG("%zd", apdu_len); + + /* XXX Do we need to do some filtering on the basic channel ?*/ + if (__seel_channel_is_basic(channel)) + return true; + + se = __seel_channel_get_se(channel); + if (!se) + return false; + + ace = g_hash_table_lookup(ace_hash, se); + if (!ace) + return false; + + if (!ace->rules) + return false; + + aid = __seel_channel_get_aid(channel, &aid_len); + if (!aid) + return false; + + /* a) Try to find a specific rule */ + rule = find_specific_rule(ace, aid, aid_len, hash); + if (rule) + return apdu_allowed(rule, apdu, apdu_len) ? true : false; + + /* + * a') Try to find a specific rule for another hash + * If there is such a rule, then access is denied for the + * current hash: Specific rule precedence over generic ones. + */ + if (find_specific_rule_for_aid(ace, aid, aid_len)) + return false; + + /* b) Search for a generic rule for this specific AID */ + rule = find_generic_rule_for_aid(ace, aid, aid_len); + if (rule) + return apdu_allowed(rule, apdu, apdu_len) ? true : false; + + /* c) Search for a generic rule for this specific hash */ + rule = find_generic_rule_for_hash(ace, hash); + if (rule) + return apdu_allowed(rule, apdu, apdu_len) ? true : false; + + /* d) Search for a generic rule: All apps, all AIDs */ + rule = find_generic_rule(ace); + if (rule) + return apdu_allowed(rule, apdu, apdu_len) ? true : false; + + return false; +} + +int __seel_ace_init(void) +{ + DBG(""); + + ace_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, free_ace); + return 0; +} + +void __seel_ace_cleanup(void) +{ + DBG(""); + + g_hash_table_destroy(ace_hash); + ace_hash = NULL; +}
diff --git a/neard/se/apdu.c b/neard/se/apdu.c new file mode 100644 index 0000000..0436e7e --- /dev/null +++ b/neard/se/apdu.c
@@ -0,0 +1,260 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <errno.h> + +#include "seel.h" + +struct iso7816_apdu { + uint8_t class; + uint8_t instruction; + uint8_t param1; + uint8_t param2; + uint8_t body[]; +} __attribute__((packed)); + +struct iso7816_apdu_resp { + uint8_t sw1; + uint8_t sw2; +} __attribute__((packed)); + +struct seel_apdu { + struct iso7816_apdu *apdu; + size_t length; +} __attribute__((packed)); + +#define MAX_AID_LENGTH 16 +#define MIN_AID_LENGTH 5 + +#define CLA_CHANNEL_STANDARD 0x0 +#define CLA_CHANNEL_EXTENDED 0x1 +#define CLA_PROPRIETARY_CMD 0x80 +#define CLA_PPS_CMD 0xF0 + +#define INS_MANAGE_CHANNEL 0x70 +#define INS_SELECT_FILE 0xA4 +#define INS_GET_GP_DATA 0xCA + +#define P1_SELECT_FILE_DF_NAME 0x4 + +#define APDU_RESP_TRAILER_LENGTH 0x2 /* SW1, SW2 */ + +#define CLA_CHANNEL_MASK 0xFF + +static struct seel_apdu *alloc_apdu(uint8_t class, uint8_t channel, + uint8_t instruction, + uint8_t param1, uint8_t param2, + uint8_t data_length, uint8_t *data, + int resp_length) +{ + struct seel_apdu *apdu; + struct iso7816_apdu *iso_apdu; + size_t iso_apdu_length; + uint32_t body_ptr; + + if (channel > 3) + return NULL; + + apdu = g_try_malloc(sizeof(struct seel_apdu)); + if (apdu == NULL) + return apdu; + + iso_apdu_length = sizeof(struct iso7816_apdu); + if (data_length > 0) + iso_apdu_length += 1 + data_length; + + if (resp_length >= 0) + iso_apdu_length += 1; + + apdu->apdu = g_try_malloc(iso_apdu_length); + if (apdu->apdu == NULL) { + g_free(apdu); + return NULL; + } + + iso_apdu = apdu->apdu; + iso_apdu->class = class | channel; + iso_apdu->instruction = instruction; + iso_apdu->param1 = param1; + iso_apdu->param2 = param2; + + body_ptr = 0; + if (data_length > 0) { + iso_apdu->body[0] = data_length; + memcpy(&iso_apdu->body[1], data, data_length); + body_ptr += data_length + 1; + } + + if (resp_length >= 0) + iso_apdu->body[body_ptr] = resp_length; + + apdu->length = iso_apdu_length; + + return apdu; +} + +struct seel_apdu *__seel_apdu_build(uint8_t *apdu, size_t length, uint8_t channel) +{ + struct seel_apdu *_apdu; + struct iso7816_apdu *iso_apdu; + + _apdu = g_try_malloc(sizeof(struct seel_apdu)); + if (!_apdu) + return NULL; + + _apdu->apdu = g_try_malloc(length); + if (_apdu->apdu == NULL) { + g_free(_apdu); + return NULL; + } + + if (channel > 3) { + DBG("Invalid channel number %d", channel); + channel = 0; + } + + iso_apdu = (struct iso7816_apdu *) apdu; + /* We add the channel iff CLA is not PPS */ + if ((iso_apdu->class & CLA_PPS_CMD) != CLA_PPS_CMD) + iso_apdu->class |= channel; + + _apdu->length = length; + memcpy(_apdu->apdu, apdu, length); + + return _apdu; +} + +void __seel_apdu_dump(uint8_t *apdu, size_t length) +{ + size_t i; + char *str; + + str = g_try_malloc0((3 * length) + 1); + if (str == NULL) + return; + + for (i = 0; i < length; i++) + sprintf(str + (3 * i), "%02X ", apdu[i]); + str[3 * length] = 0; + + DBG("[%zd] %s", length, str); + + g_free(str); +} + +void __seel_apdu_free(struct seel_apdu *apdu) +{ + g_free(apdu->apdu); + g_free(apdu); +} + +size_t __seel_apdu_length(struct seel_apdu *apdu) +{ + return apdu->length; +} + +uint8_t *__seel_apdu_data(struct seel_apdu *apdu) +{ + return (uint8_t *) apdu->apdu; +} + +struct seel_apdu *__seel_apdu_open_logical_channel(void) +{ + return alloc_apdu(CLA_CHANNEL_STANDARD, 0, INS_MANAGE_CHANNEL, 0, 0, + 0, NULL, 1); +} + +struct seel_apdu *__seel_apdu_close_logical_channel(uint8_t channel) +{ + DBG("%d", channel); + + return alloc_apdu(CLA_CHANNEL_STANDARD, 0, INS_MANAGE_CHANNEL, 0x80, + channel, 0, NULL, -1); +} + +struct seel_apdu *__seel_apdu_select_aid(uint8_t channel, + uint8_t *aid, size_t aid_length) +{ + DBG("%zd", aid_length); + + if (aid_length < MIN_AID_LENGTH || + aid_length > MAX_AID_LENGTH) + return NULL; + + return alloc_apdu(CLA_CHANNEL_STANDARD, channel, INS_SELECT_FILE, + P1_SELECT_FILE_DF_NAME, 0, + aid_length, aid, -1); +} + +struct seel_apdu *__seel_apdu_get_all_gp_data(void) +{ + DBG(""); + + return alloc_apdu(CLA_PROPRIETARY_CMD, 0, INS_GET_GP_DATA, + 0xFF, 0x40, 0, NULL, 0); +} + +struct seel_apdu *__seel_apdu_get_next_gp_data(size_t length) +{ + DBG(""); + + return alloc_apdu(CLA_PROPRIETARY_CMD, 0, INS_GET_GP_DATA, + 0xFF, 0x60, 0, NULL, length); +} + +struct seel_apdu *__seel_apdu_get_refresh_gp_data(void) +{ + DBG(""); + + return alloc_apdu(CLA_PROPRIETARY_CMD, 0, INS_GET_GP_DATA, + 0xDF, 0x20, 0, NULL, 0xB); +} + +static int apdu_trailer_status(struct iso7816_apdu_resp *trailer) +{ + DBG("SW1 0x%x SW2 0x%x", trailer->sw1, trailer->sw2); + + switch (trailer->sw1) { + case 0x90: + if (trailer->sw2 == 0) + return 0; + default: + return -EIO; + } +} + +int __seel_apdu_resp_status(uint8_t *apdu, size_t apdu_length) +{ + struct iso7816_apdu_resp *resp; + + if (apdu_length < APDU_RESP_TRAILER_LENGTH) + return -EINVAL; + + __seel_apdu_dump(apdu, apdu_length); + + resp = (struct iso7816_apdu_resp *)(apdu + apdu_length - APDU_RESP_TRAILER_LENGTH); + + return apdu_trailer_status(resp); +}
diff --git a/neard/se/channel.c b/neard/se/channel.c new file mode 100644 index 0000000..38e94ab --- /dev/null +++ b/neard/se/channel.c
@@ -0,0 +1,269 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <errno.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "driver.h" +#include "seel.h" + +struct seel_channel { + char *path; + + struct seel_se *se; + uint8_t channel; + uint8_t *aid; + size_t aid_len; + bool basic; +}; + +static DBusMessage *get_properties(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct seel_channel *channel = data; + DBusMessage *reply; + DBusMessageIter array, dict; + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append(reply, &array); + + near_dbus_dict_open(&array, &dict); + + near_dbus_dict_append_basic(&dict, "Basic", + DBUS_TYPE_BOOLEAN, &channel->basic); + + near_dbus_dict_append_fixed_array(&dict, "AID", DBUS_TYPE_BYTE, + &channel->aid, channel->aid_len); + + near_dbus_dict_close(&array, &dict); + + return reply; +} + +static void send_apdu_cb(void *context, + uint8_t *apdu, size_t apdu_length, + int err) +{ + DBusMessage *pending_msg = context; + DBusConnection *conn; + + conn = near_dbus_get_connection(); + + if (err) { + DBusMessage *reply; + + reply = __near_error_failed(pending_msg, -err); + + g_dbus_send_message(conn, reply); + dbus_message_unref(pending_msg); + + return; + } + + g_dbus_send_reply(conn, pending_msg, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &apdu, apdu_length, + DBUS_TYPE_INVALID); + + dbus_message_unref(pending_msg); + + DBG(""); +} + +static DBusMessage *send_apdu(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct seel_channel *channel = data; + DBusMessage *pending_msg; + struct seel_apdu *send_apdu; + uint8_t *apdu, *app_hash; + const GSList *app_hashes, *list; + size_t apdu_len; + const char *sender; + int err; + + DBG("conn %p", conn); + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &apdu, &apdu_len, DBUS_TYPE_INVALID)) + return __near_error_invalid_arguments(msg); + + sender = dbus_message_get_sender(msg); + app_hashes = __seel_se_get_hashes(channel->se, sender); + + for (list = app_hashes; list; list = list->next) { + app_hash = list->data; + + if (__seel_ace_apdu_allowed(channel, app_hash, apdu, apdu_len)) + goto send_data; + } + + near_error("*** APDU not allowed ***"); + return __near_error_permission_denied(msg); + +send_data: + pending_msg = dbus_message_ref(msg); + + send_apdu = __seel_apdu_build(apdu, apdu_len, channel->channel); + if (!send_apdu) { + dbus_message_unref(pending_msg); + return __near_error_out_of_memory(msg); + } + + err = __seel_se_queue_io(channel->se, send_apdu, + send_apdu_cb, pending_msg); + if (err < 0) { + near_error("send apdu error %d", err); + return NULL; + } + + return NULL; +} + +static const GDBusMethodTable channel_methods[] = { + { GDBUS_METHOD("GetProperties", + NULL, GDBUS_ARGS({"properties", "a{sv}"}), + get_properties) }, + { GDBUS_ASYNC_METHOD("SendAPDU", + GDBUS_ARGS({"apdu", "ay"}), + GDBUS_ARGS({"resp", "ay"}), + send_apdu) }, + { }, +}; + +static const GDBusSignalTable channel_signals[] = { + { GDBUS_SIGNAL("PropertyChanged", + GDBUS_ARGS({"name", "s"}, {"value", "v"})) }, + { } +}; + +struct seel_channel *__seel_channel_add(struct seel_se *se, uint8_t chn, + uint8_t *aid, size_t aid_len, bool basic) +{ + struct seel_channel *channel; + const char *se_path; + char *path; + DBusConnection *conn; + + DBG(""); + + conn = near_dbus_get_connection(); + + se_path = __seel_se_get_path(se); + if (!se_path) + return NULL; + + path = g_try_malloc0(strlen(se_path) + 16); + if (!path) + return NULL; + + g_snprintf(path, strlen(se_path) + 16, "%s/channel%d", se_path, chn); + + DBG("%s", path); + + channel = g_try_malloc0(sizeof(struct seel_channel)); + if (!channel) { + g_free(path); + return NULL; + } + + if (aid && aid_len) { + channel->aid = g_try_malloc0(aid_len); + if (!channel->aid) { + g_free(path); + g_free(channel); + return NULL; + } + + memcpy(channel->aid, aid, aid_len); + } + + channel->aid_len = aid_len; + channel->se = se; + channel->path = path; + channel->basic = basic; + channel->channel = chn; + + g_dbus_register_interface(conn, channel->path, + SEEL_CHANNEL_INTERFACE, + channel_methods, channel_signals, + NULL, channel, NULL); + + return channel; +} + +void __seel_channel_remove(struct seel_channel *channel) +{ + DBusConnection *conn; + + DBG(""); + + conn = near_dbus_get_connection(); + + g_dbus_unregister_interface(conn, channel->path, + SEEL_CHANNEL_INTERFACE); + + g_free(channel->path); + g_free(channel->aid); + g_free(channel); +} + +char *__seel_channel_get_path(struct seel_channel *channel) +{ + return channel->path; +} + +uint8_t __seel_channel_get_channel(struct seel_channel *channel) +{ + return channel->channel; +} + +uint8_t *__seel_channel_get_aid(struct seel_channel *channel, size_t *aid_len) +{ + if (!channel->aid || !channel->aid_len) + return NULL; + + *aid_len = channel->aid_len; + + return channel->aid; +} + +struct seel_se *__seel_channel_get_se(struct seel_channel *channel) +{ + return channel->se; +} + +bool __seel_channel_is_basic(struct seel_channel *channel) +{ + return channel->basic; +}
diff --git a/neard/se/driver.c b/neard/se/driver.c new file mode 100644 index 0000000..4fcbe4a --- /dev/null +++ b/neard/se/driver.c
@@ -0,0 +1,157 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <errno.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "driver.h" +#include "seel.h" + +static GSList *ctrl_driver_list; +static GSList *io_driver_list; +static struct seel_cert_driver *cert_driver; + +static gint cmp_io_prio(gconstpointer a, gconstpointer b) +{ + const struct seel_io_driver *driver1 = a; + const struct seel_io_driver *driver2 = b; + + return driver2->priority - driver1->priority; +} + +int seel_io_driver_register(struct seel_io_driver *driver) +{ + DBG(""); + + if (driver->transceive == NULL) + return -EINVAL; + + io_driver_list = g_slist_insert_sorted(io_driver_list, driver, cmp_io_prio); + + return 0; +} + +void seel_io_driver_unregister(struct seel_io_driver *driver) +{ + DBG(""); + + io_driver_list = g_slist_remove(io_driver_list, driver); +} + +static gint cmp_ctrl_prio(gconstpointer a, gconstpointer b) +{ + const struct seel_ctrl_driver *driver1 = a; + const struct seel_ctrl_driver *driver2 = b; + + return driver2->priority - driver1->priority; +} + +int seel_ctrl_driver_register(struct seel_ctrl_driver *driver) +{ + DBG(""); + + if (driver->enable_se == NULL || driver->disable_se == NULL) + return -EINVAL; + + ctrl_driver_list = g_slist_insert_sorted(ctrl_driver_list, driver, cmp_ctrl_prio); + + return 0; +} + +void seel_ctrl_driver_unregister(struct seel_ctrl_driver *driver) +{ + DBG(""); + + ctrl_driver_list = g_slist_remove(ctrl_driver_list, driver); +} + +int seel_cert_driver_register(struct seel_cert_driver *driver) +{ + DBG(""); + + if (!driver->get_hashes) + return -EINVAL; + + /* + * OS should provide unified method to get the certificate + * then we only allow register one certificate driver + */ + if (cert_driver) { + near_error("Certificate driver already registered"); + return -EALREADY; + } + + cert_driver = driver; + + return 0; +} + +void seel_cert_driver_unregister(struct seel_cert_driver *driver) +{ + DBG(""); + + cert_driver = NULL; +} + +struct seel_ctrl_driver * +__seel_driver_ctrl_find(enum seel_controller_type type) +{ + GSList *list; + + for (list = ctrl_driver_list; list; list = list->next) { + struct seel_ctrl_driver *driver = list->data; + + DBG("driver type 0x%x", driver->type); + + if (driver->type == type) + return driver; + } + + return NULL; +} + +struct seel_io_driver * +__seel_driver_io_find(enum seel_se_type type) +{ + GSList *list; + + for (list = io_driver_list; list; list = list->next) { + struct seel_io_driver *driver = list->data; + + DBG("driver type 0x%x", driver->type); + + if (driver->type == type) + return driver; + } + + return NULL; +} + +struct seel_cert_driver *__seel_driver_cert_get(void) +{ + return cert_driver; +}
diff --git a/neard/se/driver.h b/neard/se/driver.h new file mode 100644 index 0000000..99c9f1e --- /dev/null +++ b/neard/se/driver.h
@@ -0,0 +1,73 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifndef __SEEL_DRIVER_H +#define __SEEL_DRIVER_H + +#define SEEL_DRIVER_PRIORITY_LOW -100 +#define SEEL_DRIVER_PRIORITY_DEFAULT 0 +#define SEEL_DRIVER_PRIORITY_HIGH 100 + +enum seel_controller_type { + SEEL_CONTROLLER_NFC = 0, + SEEL_CONTROLLER_MODEM, + SEEL_CONTROLLER_ASSD, + SEEL_CONTROLLER_PCSC, + SEEL_CONTROLLER_UNKNOWN = 0xff +}; + +enum seel_se_type { + SEEL_SE_NFC = 0, /* Embedded SE on NFC */ + SEEL_SE_ASSD, /* Advanced Security SD SE */ + SEEL_SE_PCSC, /* PCSC compatible SE */ + SEEL_SE_UICC, /* SIM card SE */ + SEEL_SE_UNKNOWN = 0xff +}; + +struct seel_ctrl_driver { + enum seel_controller_type type; + int priority; + + int (*enable_se)(uint8_t ctrl_idx, uint32_t se_idx); + int (*disable_se)(uint8_t ctrl_idx, uint32_t se_idx); +}; + +typedef void (*transceive_cb_t)(void *context, + uint8_t *apdu, size_t apdu_length, + int err); +struct seel_io_driver { + enum seel_se_type type; + int priority; + + int (*transceive)(uint8_t ctrl_idx, uint32_t se_idx, + uint8_t *apdu, size_t apdu_length, + transceive_cb_t cb, void *context); +}; + +struct seel_cert_driver { + GSList * (*get_hashes)(pid_t pid); +}; + +int seel_io_driver_register(struct seel_io_driver *driver); +void seel_io_driver_unregister(struct seel_io_driver *driver); + +int seel_ctrl_driver_register(struct seel_ctrl_driver *driver); +void seel_ctrl_driver_unregister(struct seel_ctrl_driver *driver); + +int seel_cert_driver_register(struct seel_cert_driver *driver); +void seel_cert_driver_unregister(struct seel_cert_driver *driver); +#endif
diff --git a/neard/se/main.c b/neard/se/main.c new file mode 100644 index 0000000..009b7a3 --- /dev/null +++ b/neard/se/main.c
@@ -0,0 +1,223 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <signal.h> +#include <sys/signalfd.h> + +#include <gdbus.h> + +#include "seel.h" + +static GMainLoop *main_loop = NULL; + +static volatile sig_atomic_t __terminated = 0; + +static gboolean signal_handler(GIOChannel *channel, GIOCondition cond, + gpointer user_data) +{ + struct signalfd_siginfo si; + ssize_t result; + int fd; + + if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) + return FALSE; + + fd = g_io_channel_unix_get_fd(channel); + + result = read(fd, &si, sizeof(si)); + if (result != sizeof(si)) + return FALSE; + + switch (si.ssi_signo) { + case SIGINT: + case SIGTERM: + if (__terminated == 0) { + near_info("Terminating"); + g_main_loop_quit(main_loop); + } + + __terminated = 1; + break; + } + + return TRUE; +} + +static guint setup_signalfd(void) +{ + GIOChannel *channel; + guint source; + sigset_t mask; + int fd; + + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGTERM); + + if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) { + perror("Failed to set signal mask"); + return 0; + } + + fd = signalfd(-1, &mask, 0); + if (fd < 0) { + perror("Failed to create signal descriptor"); + return 0; + } + + channel = g_io_channel_unix_new(fd); + + g_io_channel_set_close_on_unref(channel, TRUE); + g_io_channel_set_encoding(channel, NULL, NULL); + g_io_channel_set_buffered(channel, FALSE); + + source = g_io_add_watch(channel, + G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, + signal_handler, NULL); + + g_io_channel_unref(channel); + + return source; +} + +static void disconnect_callback(DBusConnection *conn, void *user_data) +{ + near_error("D-Bus disconnect"); + + g_main_loop_quit(main_loop); +} + +static gchar *option_debug = NULL; +static gchar *option_plugin = NULL; +static gchar *option_noplugin = NULL; +static gboolean option_detach = TRUE; +static gboolean option_version = FALSE; + +static gboolean parse_debug(const char *key, const char *value, + gpointer user_data, GError **error) +{ + if (value) + option_debug = g_strdup(value); + else + option_debug = g_strdup("*"); + + return TRUE; +} + +static GOptionEntry options[] = { + { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG, + G_OPTION_ARG_CALLBACK, parse_debug, + "Specify debug options to enable", "DEBUG" }, + { "nodaemon", 'n', G_OPTION_FLAG_REVERSE, + G_OPTION_ARG_NONE, &option_detach, + "Don't fork daemon to background" }, + { "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin, + "Specify plugins to load", "NAME,..." }, + { "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin, + "Specify plugins not to load", "NAME,..." }, + { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version, + "Show version information and exit" }, + { NULL }, +}; + +int main(int argc, char *argv[]) +{ + GOptionContext *context; + GError *error = NULL; + DBusConnection *conn; + DBusError err; + guint signal; + + context = g_option_context_new(NULL); + g_option_context_add_main_entries(context, options, NULL); + + if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) { + if (error != NULL) { + g_printerr("%s\n", error->message); + g_error_free(error); + } else + g_printerr("An unknown error occurred\n"); + exit(1); + } + + g_option_context_free(context); + + if (option_version == TRUE) { + printf("%s\n", VERSION); + exit(0); + } + + main_loop = g_main_loop_new(NULL, FALSE); + + signal = setup_signalfd(); + + dbus_error_init(&err); + + conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, SEEL_SERVICE, &err); + if (conn == NULL) { + if (dbus_error_is_set(&err) == TRUE) { + fprintf(stderr, "%s\n", err.message); + dbus_error_free(&err); + } else + fprintf(stderr, "Can't register with system bus\n"); + exit(1); + } + + g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); + + __near_log_init(option_debug, option_detach); + __near_dbus_init(conn); + __seel_manager_init(conn); + __seel_ace_init(); + __seel_se_init(conn); + + __near_plugin_init(option_plugin, option_noplugin); + + if (option_detach == TRUE) { + if (daemon(0, 0)) { + perror("Can't start daemon"); + exit(1); + } + } + + g_main_loop_run(main_loop); + + g_source_remove(signal); + + __near_plugin_cleanup(); + + __seel_se_cleanup(); + __seel_ace_cleanup(); + __seel_manager_cleanup(); + __near_dbus_cleanup(); + __near_log_cleanup(); + + dbus_connection_unref(conn); + + g_main_loop_unref(main_loop); + + return 0; +} +
diff --git a/neard/se/manager.c b/neard/se/manager.c new file mode 100644 index 0000000..f30fd61 --- /dev/null +++ b/neard/se/manager.c
@@ -0,0 +1,147 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <errno.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "manager.h" +#include "seel.h" + +static DBusConnection *connection; + +static DBusMessage *get_properties(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + DBusMessageIter array, dict; + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append(reply, &array); + + near_dbus_dict_open(&array, &dict); + + near_dbus_dict_append_array(&dict, "SecureElements", + DBUS_TYPE_OBJECT_PATH, __seel_se_list, NULL); + + near_dbus_dict_close(&array, &dict); + + return reply; +} + +int seel_manager_se_add(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t se_type, uint8_t ctrl_type) +{ + char *se_path; + + se_path = __seel_se_add(se_idx, ctrl_idx, se_type, ctrl_type); + if (se_path == NULL) + return -ENOMEM; + + DBG("Adding %s", se_path); + + g_dbus_emit_signal(connection, "/", + SEEL_MANAGER_INTERFACE, "SecureElementAdded", + DBUS_TYPE_OBJECT_PATH, &se_path, + DBUS_TYPE_INVALID); + + return 0; +} + +int seel_manager_se_remove(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t ctrl_type) +{ + struct seel_se *se; + char *se_path; + int err; + + se = __seel_se_get(se_idx, ctrl_idx, ctrl_type); + if (se == NULL) + return -ENODEV; + + se_path = g_strdup(__seel_se_get_path(se)); + if (se_path == NULL) + return -EINVAL; + + err = __seel_se_remove(se_idx, ctrl_idx, ctrl_type); + if (err < 0) + return err; + + g_dbus_emit_signal(connection, "/", + SEEL_MANAGER_INTERFACE, "SecureElementRemoved", + DBUS_TYPE_OBJECT_PATH, &se_path, + DBUS_TYPE_INVALID); + + g_free(se_path); + + return 0; +} + +static const GDBusMethodTable manager_methods[] = { + { GDBUS_METHOD("GetProperties", + NULL, GDBUS_ARGS({"properties", "a{sv}"}), + get_properties) }, + { }, +}; + +static const GDBusSignalTable manager_signals[] = { + { GDBUS_SIGNAL("SecureElementAdded", GDBUS_ARGS({"se", "o" })) }, + { GDBUS_SIGNAL("SecureElementRemoved", GDBUS_ARGS({"se", "o" })) }, + { } +}; + +int __seel_manager_init(DBusConnection *conn) +{ + DBG(""); + + connection = dbus_connection_ref(conn); + + DBG("connection %p", connection); + + g_dbus_register_interface(connection, SEEL_MANAGER_PATH, + SEEL_MANAGER_INTERFACE, + manager_methods, + manager_signals, + NULL, NULL, NULL); + + return 0; +} + +void __seel_manager_cleanup(void) +{ + DBG(""); + + g_dbus_unregister_interface(connection, SEEL_MANAGER_PATH, + SEEL_MANAGER_INTERFACE); + + dbus_connection_unref(connection); +} +
diff --git a/neard/se/manager.h b/neard/se/manager.h new file mode 100644 index 0000000..99593fb --- /dev/null +++ b/neard/se/manager.h
@@ -0,0 +1,22 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +int seel_manager_se_add(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t se_type, uint8_t ctrl_type); + +int seel_manager_se_remove(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t ctrl_type);
diff --git a/neard/se/org.neard.se.conf b/neard/se/org.neard.se.conf new file mode 100644 index 0000000..02d319a --- /dev/null +++ b/neard/se/org.neard.se.conf
@@ -0,0 +1,14 @@ +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + <policy user="root"> + <allow own="org.neard.se"/> + <allow send_destination="org.neard.se"/> + </policy> + <policy at_console="true"> + <allow send_destination="org.neard.se"/> + </policy> + <policy context="default"> + <deny send_destination="org.neard.se"/> + </policy> +</busconfig>
diff --git a/neard/se/plugins/nfc.c b/neard/se/plugins/nfc.c new file mode 100644 index 0000000..75aba3b --- /dev/null +++ b/neard/se/plugins/nfc.c
@@ -0,0 +1,724 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <errno.h> + +#include <sys/socket.h> +#include <linux/socket.h> + +#include <glib.h> + +#include <netlink/netlink.h> +#include <netlink/genl/genl.h> +#include <netlink/genl/family.h> +#include <netlink/genl/ctrl.h> + +#include <near/log.h> +#include <near/plugin.h> +#include <near/nfc_copy.h> + +#include "../manager.h" +#include "../driver.h" + + +#ifdef NEED_LIBNL_COMPAT +#define nl_sock nl_handle + +static inline struct nl_handle *nl_socket_alloc(void) +{ + return nl_handle_alloc(); +} + +static inline void nl_socket_free(struct nl_sock *h) +{ + nl_handle_destroy(h); +} + +#define NLE_MISSING_ATTR 14 + +static inline void __nl_perror(int error, const char *s) +{ + nl_perror(s); +} +#define nl_perror __nl_perror +#endif + +struct nfc_transceive_context { + void *context; + uint8_t *apdu; + size_t apdu_length; + transceive_cb_t cb; +}; + +struct nlnfc_state { + struct nl_sock *cmd_sock; + struct nl_sock *event_sock; + int nfc_id; + int mcid; + + struct nfc_transceive_context *ctx; +}; + +static struct nlnfc_state *nfc_state; +static GIOChannel *netlink_channel = NULL; + +static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, + void *arg) +{ + int *ret = arg; + + DBG(""); + + *ret = err->error; + + return NL_STOP; +} + +static int finish_handler(struct nl_msg *msg, void *arg) +{ + int *ret = arg; + + DBG(""); + + *ret = 1; + + return NL_SKIP; +} + +static int ack_handler(struct nl_msg *msg, void *arg) +{ + int *ret = arg; + + DBG(""); + + *ret = 1; + + return NL_STOP; +} + +static int nl_send_msg(struct nl_sock *sock, struct nl_msg *msg, + int (*rx_handler)(struct nl_msg *, void *), + void *data) +{ + struct nl_cb *cb; + int err, done; + + DBG(""); + + cb = nl_cb_alloc(NL_CB_DEFAULT); + if (cb == NULL) + return -ENOMEM; + + err = nl_send_auto_complete(sock, msg); + if (err < 0) { + nl_cb_put(cb); + near_error("%s", strerror(err)); + + return err; + } + + err = done = 0; + + nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err); + nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &done); + nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &done); + + if (rx_handler != NULL) + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, rx_handler, data); + + while (err == 0 && done == 0) + nl_recvmsgs(sock, cb); + + nl_cb_put(cb); + + return err; +} + +static int no_seq_check(struct nl_msg *n, void *arg) +{ + DBG(""); + + return NL_OK; +} + +static enum seel_se_type nfc_se_type(uint32_t se_type) +{ + switch (se_type) { + case NFC_SE_UICC: + return SEEL_SE_UICC; + case NFC_SE_EMBEDDED: + return SEEL_SE_NFC; + } + + return SEEL_SE_UNKNOWN; +} + +static int nfc_netlink_event_se(struct genlmsghdr *gnlh, bool add) +{ + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + uint32_t nfc_idx, se_idx; + + DBG(""); + + nla_parse(attrs, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (attrs[NFC_ATTR_DEVICE_INDEX] == NULL) { + near_error("Missing NFC controller index"); + return -ENODEV; + } + + if (attrs[NFC_ATTR_SE_INDEX] == NULL) { + near_error("Missing NFC SE index"); + return -ENODEV; + } + + nfc_idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + se_idx = nla_get_u32(attrs[NFC_ATTR_SE_INDEX]); + + DBG("NFC %d SE %d", nfc_idx, se_idx); + + if (add) { + uint8_t se_type, seel_se_type; + + if (attrs[NFC_ATTR_SE_TYPE] == NULL) { + near_error("Missing SE type attribute"); + return -EINVAL; + } + + se_type = nla_get_u8(attrs[NFC_ATTR_SE_TYPE]); + seel_se_type = nfc_se_type(se_type); + DBG("NFC SE type %d %d", se_type, seel_se_type); + + return seel_manager_se_add(se_idx, nfc_idx, seel_se_type, + SEEL_CONTROLLER_NFC); + } else { + return seel_manager_se_remove(se_idx, nfc_idx, + SEEL_CONTROLLER_NFC); + } +} + +static int nfc_netlink_event_io(struct genlmsghdr *gnlh) +{ + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + uint32_t nfc_idx, se_idx; + uint8_t *apdu; + size_t apdu_len; + int err; + + DBG(""); + + if (!nfc_state->ctx) + return -EINVAL; + + nla_parse(attrs, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (!attrs[NFC_ATTR_DEVICE_INDEX]) { + near_error("Missing NFC controller index"); + err = -ENODEV; + goto out; + } + + if (!attrs[NFC_ATTR_SE_INDEX]) { + near_error("Missing NFC SE index"); + err = -ENODEV; + goto out; + } + + if (!attrs[NFC_ATTR_SE_APDU]) { + near_error("Missing SE APDU"); + err = -EIO; + goto out; + } + + nfc_idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + se_idx = nla_get_u32(attrs[NFC_ATTR_SE_INDEX]); + apdu_len = nla_len(attrs[NFC_ATTR_SE_APDU]); + if (!apdu_len) { + err = -EINVAL; + goto out; + } + + apdu = nla_data(attrs[NFC_ATTR_SE_APDU]); + if (!apdu) { + err = -EINVAL; + goto out; + } + + DBG("NFC %d SE %d APDU len %zd", nfc_idx, se_idx, apdu_len); + + nfc_state->ctx->cb(nfc_state->ctx->context, apdu, apdu_len, 0); + + err = 0; +out: + if (err) + nfc_state->ctx->cb(nfc_state->ctx->context, NULL, 0, err); + + g_free(nfc_state->ctx); + nfc_state->ctx = NULL; + + return err; +} + +static int nfc_netlink_event(struct nl_msg *n, void *arg) +{ + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(n)); + + DBG("event 0x%x", gnlh->cmd); + + switch (gnlh->cmd) { + case NFC_EVENT_SE_ADDED: + DBG("SE added"); + nfc_netlink_event_se(gnlh, true); + break; + + case NFC_EVENT_SE_REMOVED: + DBG("SE removed"); + nfc_netlink_event_se(gnlh, false); + break; + + case NFC_CMD_SE_IO: + DBG("SE IO"); + nfc_netlink_event_io(gnlh); + break; + } + + return NL_SKIP; +} + +static gboolean __nfc_netlink_event(GIOChannel *channel, + GIOCondition cond, gpointer data) +{ + struct nl_cb *cb; + struct nlnfc_state *state = data; + + if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) + return FALSE; + + cb = nl_cb_alloc(NL_CB_VERBOSE); + if (cb == NULL) + return TRUE; + + nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, nfc_netlink_event, data); + + nl_recvmsgs(state->event_sock, cb); + + nl_cb_put(cb); + + return TRUE; +} + +static int nfc_event_listener(struct nlnfc_state *state) +{ + int sock; + + sock = nl_socket_get_fd(state->event_sock); + netlink_channel = g_io_channel_unix_new(sock); + g_io_channel_set_close_on_unref(netlink_channel, TRUE); + + g_io_channel_set_encoding(netlink_channel, NULL, NULL); + g_io_channel_set_buffered(netlink_channel, FALSE); + + g_io_add_watch(netlink_channel, + G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR, + __nfc_netlink_event, state); + + return 0; +} + +struct handler_args { + const char *group; + int id; +}; + +static int family_handler(struct nl_msg *msg, void *arg) +{ + struct handler_args *grp = arg; + struct nlattr *tb[CTRL_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *mcgrp; + int rem_mcgrp; + + DBG(""); + + nla_parse(tb, CTRL_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (!tb[CTRL_ATTR_MCAST_GROUPS]) + return NL_SKIP; + + nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], rem_mcgrp) { + struct nlattr *tb_mcgrp[CTRL_ATTR_MCAST_GRP_MAX + 1]; + + nla_parse(tb_mcgrp, CTRL_ATTR_MCAST_GRP_MAX, + nla_data(mcgrp), nla_len(mcgrp), NULL); + + if (!tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME] || + !tb_mcgrp[CTRL_ATTR_MCAST_GRP_ID]) + continue; + if (strncmp(nla_data(tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME]), + grp->group, nla_len(tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME]))) + continue; + grp->id = nla_get_u32(tb_mcgrp[CTRL_ATTR_MCAST_GRP_ID]); + break; + } + + return NL_SKIP; +} + +static int nl_get_multicast_id(struct nl_sock *sock, const char *family, + const char *group) +{ + struct nl_msg *msg; + int err, ctrlid; + struct handler_args grp = { + .group = group, + .id = -ENOENT, + }; + + DBG(""); + + msg = nlmsg_alloc(); + if (msg == NULL) + return -ENOMEM; + + ctrlid = genl_ctrl_resolve(sock, "nlctrl"); + + genlmsg_put(msg, 0, 0, ctrlid, 0, 0, CTRL_CMD_GETFAMILY, 0); + + err = -EMSGSIZE; + + NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, family); + + err = nl_send_msg(sock, msg, family_handler, &grp); + if (err) + goto nla_put_failure; + + DBG("multicast id %d", grp.id); + + err = grp.id; + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static int nfc_toggle_se(uint8_t ctrl_idx, uint32_t se_idx, bool enable) +{ + struct nl_msg *msg; + void *hdr; + int err; + uint8_t cmd; + + DBG(""); + + msg = nlmsg_alloc(); + if (msg == NULL) + return -ENOMEM; + + if (enable == TRUE) + cmd = NFC_CMD_ENABLE_SE; + else + cmd = NFC_CMD_DISABLE_SE; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, cmd, NFC_GENL_VERSION); + if (hdr == NULL) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, ctrl_idx); + NLA_PUT_U32(msg, NFC_ATTR_SE_INDEX, se_idx); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static int get_ses_handler(struct nl_msg *n, void *arg) +{ + struct nlmsghdr *nlh = nlmsg_hdr(n); + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + uint32_t nfc_idx, se_idx; + uint8_t se_type, seel_se_type; + + DBG(""); + + genlmsg_parse(nlh, 0, attrs, NFC_ATTR_MAX, NULL); + + if (attrs[NFC_ATTR_DEVICE_INDEX] == NULL || + attrs[NFC_ATTR_SE_INDEX] == NULL || + attrs[NFC_ATTR_SE_TYPE] == NULL) { + nl_perror(NLE_MISSING_ATTR, "NFC_CMD_GET_SE"); + return NL_STOP; + } + + nfc_idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + se_idx = nla_get_u32(attrs[NFC_ATTR_SE_INDEX]); + se_type = nla_get_u8(attrs[NFC_ATTR_SE_TYPE]); + + seel_se_type = nfc_se_type(se_type); + DBG("NFC SE type %d %d", se_type, seel_se_type); + + seel_manager_se_add(se_idx, nfc_idx, seel_se_type, + SEEL_CONTROLLER_NFC); + + return NL_SKIP; +} + +static int nfc_get_ses(void) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + if (nfc_state == NULL || nfc_state->nfc_id < 0) + return -ENODEV; + + msg = nlmsg_alloc(); + if (msg == NULL) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_DUMP, NFC_CMD_GET_SE, NFC_GENL_VERSION); + if (hdr == NULL) { + err = -EINVAL; + goto out; + } + + err = nl_send_msg(nfc_state->cmd_sock, msg, get_ses_handler, NULL); + +out: + nlmsg_free(msg); + + return err; +} + +static int nfc_enable_se(uint8_t ctrl_idx, uint32_t se_idx) +{ + return nfc_toggle_se(ctrl_idx, se_idx, true); +} + +static int nfc_disable_se(uint8_t ctrl_idx, uint32_t se_idx) +{ + return nfc_toggle_se(ctrl_idx, se_idx, false); +} + +static struct seel_ctrl_driver nfc_ctrl_driver = { + .type = SEEL_CONTROLLER_NFC, + .enable_se = nfc_enable_se, + .disable_se = nfc_disable_se, +}; + +static int nfc_transceive(uint8_t ctrl_idx, uint32_t se_idx, + uint8_t *apdu, size_t apdu_length, + transceive_cb_t cb, void *context) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG("%zd APDU %p", apdu_length, apdu); + + if (nfc_state->ctx) + return -EALREADY; + + nfc_state->ctx = g_try_malloc0(sizeof(struct nfc_transceive_context)); + if (!nfc_state->ctx) { + cb(context, NULL, 0, -ENOMEM); + + return -ENOMEM; + } + + nfc_state->ctx->context = context; + nfc_state->ctx->cb = cb; + + msg = nlmsg_alloc(); + if (msg == NULL) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_SE_IO, NFC_GENL_VERSION); + if (hdr == NULL) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, ctrl_idx); + NLA_PUT_U32(msg, NFC_ATTR_SE_INDEX, se_idx); + NLA_PUT(msg, NFC_ATTR_SE_APDU, apdu_length, apdu); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static struct seel_io_driver nfc_io_driver = { + .type = SEEL_SE_NFC, + .transceive = nfc_transceive, +}; + +static int nfc_init(void) +{ + int err; + + DBG(""); + + nfc_state = g_try_malloc0(sizeof(struct nlnfc_state)); + if (nfc_state == NULL) + return -ENOMEM; + + nfc_state->cmd_sock = nl_socket_alloc(); + if (nfc_state->cmd_sock == NULL) { + near_error("Failed to allocate NFC command netlink socket"); + err = -ENOMEM; + goto state_free; + } + + nfc_state->event_sock = nl_socket_alloc(); + if (nfc_state->event_sock == NULL) { + near_error("Failed to allocate NFC event netlink socket"); + err = -ENOMEM; + goto handle_cmd_destroy; + } + + if (genl_connect(nfc_state->cmd_sock)) { + near_error("Failed to connect to generic netlink"); + err = -ENOLINK; + goto handle_event_destroy; + } + + if (genl_connect(nfc_state->event_sock)) { + near_error("Failed to connect to generic netlink"); + err = -ENOLINK; + goto handle_event_destroy; + } + + nfc_state->nfc_id = genl_ctrl_resolve(nfc_state->cmd_sock, "nfc"); + if (nfc_state->nfc_id < 0) { + near_error("Unable to find NFC netlink family"); + err = -ENOENT; + goto handle_event_destroy; + } + + nfc_state->mcid = nl_get_multicast_id(nfc_state->cmd_sock, NFC_GENL_NAME, + NFC_GENL_MCAST_EVENT_NAME); + if (nfc_state->mcid <= 0) { + near_error("Wrong mcast id %d", nfc_state->mcid); + err = nfc_state->mcid; + goto handle_event_destroy; + } + + err = nl_socket_add_membership(nfc_state->event_sock, nfc_state->mcid); + if (err) { + near_error("Error adding nl event socket to membership"); + goto handle_event_destroy; + } + + err = nfc_event_listener(nfc_state); + if (err) { + near_error("Failed to start NFC event listener"); + goto netlink_channel_destroy; + } + + err = seel_ctrl_driver_register(&nfc_ctrl_driver); + if (err) { + near_error("Could not register NFC ctrl driver"); + goto netlink_channel_destroy; + } + + err = seel_io_driver_register(&nfc_io_driver); + if (err) { + near_error("Could not register NFC IO driver"); + goto unregister_ctrl_driver; + } + + return nfc_get_ses(); + +unregister_ctrl_driver: + seel_ctrl_driver_unregister(&nfc_ctrl_driver); + +netlink_channel_destroy: + g_io_channel_shutdown(netlink_channel, TRUE, NULL); + g_io_channel_unref(netlink_channel); + + netlink_channel = NULL; + +handle_event_destroy: + nl_socket_free(nfc_state->event_sock); + +handle_cmd_destroy: + nl_socket_free(nfc_state->cmd_sock); + +state_free: + g_free(nfc_state); + + nfc_state = NULL; + + near_error("netlink init failed"); + + return err; +} + +static void nfc_exit(void) +{ + seel_ctrl_driver_unregister(&nfc_ctrl_driver); + seel_io_driver_unregister(&nfc_io_driver); + + if (netlink_channel != NULL) { + g_io_channel_shutdown(netlink_channel, TRUE, NULL); + g_io_channel_unref(netlink_channel); + + netlink_channel = NULL; + } + + if (nfc_state == NULL) + return; + + nl_socket_free(nfc_state->cmd_sock); + nl_socket_free(nfc_state->event_sock); + + g_free(nfc_state); + + DBG(""); +} + +NEAR_PLUGIN_DEFINE(nfc, "SE NFC support", VERSION, + NEAR_PLUGIN_PRIORITY_HIGH, nfc_init, nfc_exit)
diff --git a/neard/se/plugins/tizen.c b/neard/se/plugins/tizen.c new file mode 100644 index 0000000..6bdbc24 --- /dev/null +++ b/neard/se/plugins/tizen.c
@@ -0,0 +1,644 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <stdint.h> +#include <errno.h> + +#include <gdbus.h> +#include <string.h> + +#include <glib.h> + +#include "package-manager.h" +#include "pkgmgr-info.h" +#include "aul.h" + +#include <near/log.h> +#include <near/plugin.h> +#include <near/driver.h> +#include <near/dbus.h> + +#define TELEPHONY_SERVICE "org.tizen.telephony" +#define TELEPHONY_DEFAULT_PATH "/org/tizen/telephony" + +#define MANAGER_INTERFACE TELEPHONY_SERVICE ".Manager" +#define SIM_INTERFACE TELEPHONY_SERVICE ".Sim" + +/* signals */ +#define SIM_STATUS "Status" + +/* commands */ +#define GET_MODEMS "GetModems" +#define GET_INIT_STATUS "GetInitStatus" +#define TRANSFER_APDU "TransferAPDU" + +#define SIM_INIT_COMPLETED 0x03 +#define MAX_CERT_TYPE 9 + +static DBusConnection *connection; + +struct tapi_modem { + char *path; + bool sim_available; +}; +static struct tapi_modem *default_modem; +static GHashTable *modem_hash; +static GHashTable *cert_hash; + +static void check_sim_status_reply(DBusPendingCall *call, void *user_data) +{ + DBusMessage *reply; + DBusError error; + struct tapi_modem *modem = user_data; + int status; + bool changed; + + DBG(""); + + reply = dbus_pending_call_steal_reply(call); + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply) == TRUE) { + DBG("%s", error.message); + dbus_error_free(&error); + goto done; + } + + if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_INT32, &status, + DBUS_TYPE_BOOLEAN, &changed, + DBUS_TYPE_INVALID)) + goto done; + + DBG("sim status %d changed %d", status, changed); + if (status == SIM_INIT_COMPLETED) + modem->sim_available = true; + + if (default_modem == NULL && modem->sim_available == true) + default_modem = modem; + +done: + dbus_message_unref(reply); + dbus_pending_call_unref(call); +} + +static void check_sim_status(gpointer key, gpointer value, gpointer user_data) +{ + DBusMessage *message; + DBusPendingCall *call; + struct tapi_modem *modem = value; + + DBG(""); + + if (modem == NULL) + return; + + message = dbus_message_new_method_call(TELEPHONY_SERVICE, + modem->path, SIM_INTERFACE, + GET_INIT_STATUS); + if (message == NULL) + return; + + if (dbus_connection_send_with_reply(connection, message, + &call, -1) == FALSE) { + DBG("Failed to call GetInitStatus()"); + dbus_message_unref(message); + return; + } + + if (call == NULL) { + DBG("D-Bus connection not available"); + dbus_message_unref(message); + return; + } + + dbus_pending_call_set_notify(call, check_sim_status_reply, + modem, NULL); + + dbus_message_unref(message); +} + +static void add_modem(const char *path) +{ + struct tapi_modem *modem; + + DBG("modem_path %s", path); + + modem = g_hash_table_lookup(modem_hash, path); + if (modem != NULL) + return; + + modem = g_try_new0(struct tapi_modem, 1); + if (modem == NULL) + return; + + modem->path = g_strdup(path); + modem->sim_available = false; + + g_hash_table_insert(modem_hash, g_strdup(modem->path), modem); +} + +static void remove_modem(gpointer user_data) +{ + struct tapi_modem *modem = user_data; + + g_free(modem->path); + g_free(modem); +} + +static void get_modems_reply(DBusPendingCall *call, void *user_data) +{ + DBusMessage *reply; + DBusError error; + DBusMessageIter array, entry; + + DBG(""); + + reply = dbus_pending_call_steal_reply(call); + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply) == TRUE) { + DBG("%s", error.message); + dbus_error_free(&error); + goto done; + } + + if (dbus_message_iter_init(reply, &array) == FALSE) + goto done; + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY) + goto done; + + dbus_message_iter_recurse(&array, &entry); + while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRING) { + const char *name, *path; + + dbus_message_iter_get_basic(&entry, &name); + + path = g_strdup_printf("%s/%s", TELEPHONY_DEFAULT_PATH, name); + if (path != NULL) { + add_modem(path); + g_free(path); + } + + dbus_message_iter_next(&entry); + } + + g_hash_table_foreach(modem_hash, check_sim_status, NULL); + +done: + dbus_message_unref(reply); + dbus_pending_call_unref(call); +} + +static int get_modems(void) +{ + DBusMessage *message; + DBusPendingCall *call; + + DBG(""); + + message = dbus_message_new_method_call(TELEPHONY_SERVICE, + TELEPHONY_DEFAULT_PATH, + MANAGER_INTERFACE, GET_MODEMS); + if (message == NULL) + return -ENOMEM; + + if (dbus_connection_send_with_reply(connection, message, + &call, -1) == FALSE) { + DBG("Failed to call GetModems()"); + dbus_message_unref(message); + return -EINVAL; + } + + if (call == NULL) { + DBG("D-Bus connection not available"); + dbus_message_unref(message); + return -EINVAL; + } + + dbus_pending_call_set_notify(call, get_modems_reply, + NULL, NULL); + + dbus_message_unref(message); + + return -EINPROGRESS; +} + +static void remove_cert_list(gpointer user_data) +{ + g_free(user_data); +} + +static void remove_cert(gpointer user_data) +{ + GSList *cert_list = user_data; + + g_slist_free_full(cert_list, remove_cert_list); +} + +static void tapi_connect(DBusConnection *conn, void *user_data) +{ + DBG(""); + + modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, remove_modem); + if (modem_hash == NULL) + return; + + cert_hash = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, remove_cert); + if (cert_hash == NULL) + return; + + get_modems(); +} + +static void tapi_disconnect(DBusConnection *conn, void *user_data) +{ + DBG("connection %p", connection); + + if (modem_hash == NULL) + return; + + g_hash_table_destroy(modem_hash); + modem_hash = NULL; + + if (cert_hash == NULL) + return; + + g_hash_table_destroy(cert_hash); + cert_hash = NULL; + +} + +static gboolean sim_changed(DBusConnection *conn, DBusMessage *message, + void *user_data) +{ + const char *path = dbus_message_get_path(message); + struct tapi_modem *modem; + int status; + + DBG("modem_path %s", path); + + modem = g_hash_table_lookup(modem_hash, path); + if (modem == NULL) + return TRUE; + + if (!dbus_message_get_args(message, NULL, DBUS_TYPE_INT32, &status, + DBUS_TYPE_INVALID)) + return TRUE; + + DBG("sim status %d", status); + if (status == SIM_INIT_COMPLETED) + modem->sim_available = true; + else + modem->sim_available = false; + + if (default_modem == modem && modem->sim_available == false) + default_modem = NULL; + + if (default_modem == NULL && modem->sim_available == true) + default_modem = modem; + + return TRUE; +} + +struct tapi_transceive_context { + void *context; + transceive_cb_t cb; +}; + +static void tapi_transfer_apdu_reply(DBusPendingCall *call, void *user_data) +{ + struct tapi_transceive_context *ctx = user_data; + DBusMessage *reply; + DBusError error; + DBusMessageIter iter, array, entry; + uint8_t *apdu = NULL; + int result = -EIO, apdu_length = 0; + + DBG(""); + + reply = dbus_pending_call_steal_reply(call); + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply) == TRUE) { + DBG("%s", error.message); + dbus_error_free(&error); + goto done; + } + + if (dbus_message_iter_init(reply, &iter) == FALSE) + goto done; + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32) + goto done; + + dbus_message_iter_get_basic(&iter, &result); + + dbus_message_iter_next(&iter); + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) + goto done; + + dbus_message_iter_recurse(&iter, &array); + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY) + goto done; + + dbus_message_iter_recurse(&array, &entry); + dbus_message_iter_get_fixed_array(&entry, &apdu, &apdu_length); + + if (apdu_length == 0 || apdu == NULL) + DBG("data is NULL"); + + DBG("apdu_length %d", apdu_length); + +done: + ctx->cb(ctx->context, apdu, apdu_length, result); + g_free(ctx); + + dbus_message_unref(reply); + dbus_pending_call_unref(call); +} + +static int tapi_transceive(uint8_t ctrl_idx, uint32_t se_idx, + uint8_t *apdu, size_t apdu_length, + transceive_cb_t cb, void *context) +{ + DBusMessage *message; + DBusMessageIter iter; + DBusMessageIter value, array; + DBusPendingCall *call; + struct tapi_transceive_context *ctx; + int err; + + DBG("%zd APDU %p", apdu_length, apdu); + + if (default_modem == NULL) { + err = -EIO; + goto fail; + } + + ctx = g_try_malloc0(sizeof(struct tapi_transceive_context)); + if (ctx == NULL) { + err = -ENOMEM; + goto fail; + } + + ctx->context = context; + ctx->cb = cb; + + message = dbus_message_new_method_call(TELEPHONY_SERVICE, + default_modem->path, + SIM_INTERFACE, TRANSFER_APDU); + + if (message == NULL) { + err = -ENOMEM; + goto fail; + } + + dbus_message_iter_init_append(message, &iter); + dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, + DBUS_TYPE_ARRAY_AS_STRING + DBUS_TYPE_BYTE_AS_STRING, + &value); + dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, + &array); + dbus_message_iter_append_fixed_array(&array, DBUS_TYPE_BYTE, + &apdu, apdu_length); + dbus_message_iter_close_container(&value, &array); + dbus_message_iter_close_container(&iter, &value); + + if (dbus_connection_send_with_reply(connection, message, + &call, -1) == FALSE) { + DBG("Failed to Transfer APDU through UICC"); + dbus_message_unref(message); + err = -EINVAL; + goto fail; + } + + if (call == NULL) { + DBG("D-Bus connection not available"); + dbus_message_unref(message); + err = -EINVAL; + goto fail; + } + + dbus_pending_call_set_notify(call, tapi_transfer_apdu_reply, + ctx, NULL); + dbus_message_unref(message); + + return 0; + +fail: + cb(context, NULL, 0, err); + if (ctx != NULL) + g_free(ctx); + + return err; +} + +static struct seel_io_driver tizen_io_driver = { + .type = SEEL_SE_UICC, + .transceive = tapi_transceive, +}; + +static uint8_t *digest_cert(const char *cert, int length) +{ + GChecksum *checksum; + uint8_t *hash; + gsize digest_len; + + if (cert == NULL || length < 0) + return NULL; + + digest_len = g_checksum_type_get_length(G_CHECKSUM_SHA1); + hash = g_try_malloc(digest_len); + if (hash == NULL) + return NULL; + + checksum = g_checksum_new(G_CHECKSUM_SHA1); + if (checksum == NULL) { + g_free(hash); + return NULL; + } + + g_checksum_update(checksum, cert, length); + + g_checksum_get_digest(checksum, hash, &digest_len); + + DBG("Digest is: "); + __seel_apdu_dump(hash, digest_len); + + g_checksum_free(checksum); + + return hash; +} + +static GSList *tizen_get_hashes(pid_t pid) +{ + char pkg_name[256] = { 0, }; + pkgmgrinfo_appinfo_h appinfo; + pkgmgr_certinfo_h certinfo; + GSList *cert_list = NULL; + char *pkgid; + int i; + + DBG(""); + + if (aul_app_get_pkgname_bypid(pid, pkg_name, sizeof(pkg_name)) < 0) + return NULL; + + if (pkgmgrinfo_appinfo_get_appinfo(pkg_name, &appinfo) < 0) + return NULL; + + if (pkgmgrinfo_appinfo_get_pkgid(appinfo, &pkgid) < 0) + goto destroy_appinfo; + + DBG("Package ID %s", pkgid); + + cert_list = g_hash_table_lookup(cert_hash, pkgid); + if (cert_list != NULL) + return cert_list; + + if (pkgmgr_pkginfo_create_certinfo(&certinfo) < 0) + goto destroy_appinfo; + + if (pkgmgr_pkginfo_load_certinfo(pkgid, certinfo) < 0) + goto destroy_certinfo; + + for (i = 0; i < MAX_CERT_TYPE; i++) { + const char *cert_64 = NULL; + const char *cert_bin = NULL; + uint8_t *hash = NULL; + gsize length; + + if (pkgmgr_pkginfo_get_cert_value(certinfo, + (pkgmgr_cert_type)i, &cert_64) < 0) + continue; + + if (cert_64 != NULL && strlen(cert_64) > 0) { + cert_bin = g_base64_decode(cert_64, &length); + + if (cert_bin != NULL && length > 0) + hash = digest_cert(cert_bin, length); + + if (hash != NULL) + cert_list = g_slist_append(cert_list, hash); + } + } + + if (cert_list != NULL) + g_hash_table_insert(cert_hash, g_strdup(pkgid), cert_list); + +destroy_certinfo: + pkgmgr_pkginfo_destroy_certinfo(certinfo); + +destroy_appinfo: + pkgmgrinfo_appinfo_destroy_appinfo(appinfo); + + return cert_list; +} + +static struct seel_cert_driver tizen_cert_driver = { + .get_hashes = tizen_get_hashes, +}; + + +static guint watch; +static guint sim_watch; + +static int tapi_init(void) +{ + int err; + + DBG(""); + + connection = near_dbus_get_connection(); + if (connection == NULL) + return -EIO; + + watch = g_dbus_add_service_watch(connection, TELEPHONY_SERVICE, + tapi_connect, tapi_disconnect, + NULL, NULL); + + sim_watch = g_dbus_add_signal_watch(connection, TELEPHONY_SERVICE, + NULL, SIM_INTERFACE, SIM_STATUS, + sim_changed, NULL, NULL); + + if (watch == 0 || sim_watch == 0) { + err = -EIO; + goto remove; + } + + err = seel_io_driver_register(&tizen_io_driver); + if (err < 0) + goto remove; + + err = seel_cert_driver_register(&tizen_cert_driver); + if (err < 0) { + seel_io_driver_unregister(&tizen_io_driver); + goto remove; + } + + return 0; + +remove: + g_dbus_remove_watch(connection, watch); + g_dbus_remove_watch(connection, sim_watch); + + dbus_connection_unref(connection); + + return err; +} + +static void tapi_exit(void) +{ + DBG(""); + + seel_io_driver_unregister(&tizen_io_driver); + seel_cert_driver_unregister(&tizen_cert_driver); + + if (modem_hash != NULL) { + g_hash_table_destroy(modem_hash); + modem_hash = NULL; + } + + if (cert_hash != NULL) { + g_hash_table_destroy(cert_hash); + cert_hash = NULL; + } + + g_dbus_remove_watch(connection, watch); + g_dbus_remove_watch(connection, sim_watch); + + dbus_connection_unref(connection); +} + +SEEL_PLUGIN_DEFINE(tizen, "Tizen telephony plugin", VERSION, + SEEL_PLUGIN_PRIORITY_HIGH, tapi_init, tapi_exit)
diff --git a/neard/se/se.c b/neard/se/se.c new file mode 100644 index 0000000..74c2e03 --- /dev/null +++ b/neard/se/se.c
@@ -0,0 +1,767 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <errno.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "manager.h" +#include "driver.h" + +#include "seel.h" + +static DBusConnection *connection; + +static GHashTable *se_hash; + +struct seel_se { + char *path; + + uint8_t ctrl_idx; + uint8_t se_idx; + + enum seel_se_type se_type; + enum seel_controller_type ctrl_type; + + struct seel_ctrl_driver *ctrl_driver; + struct seel_io_driver *io_driver; + struct seel_cert_driver *cert_driver; + + bool ioreq_pending; + GList *ioreq_list; + + struct seel_channel *basic_channel; + GHashTable *channel_hash; + + bool enabled; +}; + +struct seel_se_ioreq { + struct seel_se *se; + struct seel_apdu *apdu; + void *context; + transceive_cb_t cb; +}; + +static int send_io(struct seel_se *se); + +static void se_free(gpointer data) +{ + struct seel_se *se = data; + + g_free(se->path); +} + +static void se_channel_free(gpointer data) +{ + struct seel_channel *channel = data; + + __seel_channel_remove(channel); +} + +static void append_path(gpointer key, gpointer value, gpointer user_data) +{ + struct seel_se *se = value; + DBusMessageIter *iter = user_data; + + DBG("%s", se->path); + + if (se->path == NULL) + return; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, + &se->path); +} + +void __seel_se_list(DBusMessageIter *iter, void *user_data) +{ + g_hash_table_foreach(se_hash, append_path, iter); +} + +static gboolean send_io_bh(gpointer user_data) +{ + struct seel_se *se = user_data; + + send_io(se); + + return FALSE; +} + +static void io_cb(void *context, + uint8_t *apdu, size_t apdu_length, int err) +{ + struct seel_se_ioreq *req = context; + struct seel_se *se = req->se; + + DBG("%zd %d", apdu_length, err); + + /* Check response status */ + if (!err) + err = __seel_apdu_resp_status(apdu, apdu_length); + + req->cb(req->context, apdu, apdu_length, err); + + __seel_apdu_free(req->apdu); + g_free(req); + + se->ioreq_pending = false; + + /* + * Process the next request after the callback is + * completely done, otherwise we may hit callback + * reentrance issue whenever the callback queues + * some request as well. + */ + g_idle_add(send_io_bh, se); +} + +static int send_io(struct seel_se *se) +{ + GList *first; + struct seel_se_ioreq *req; + int err; + + DBG(""); + + se->ioreq_pending = true; + + first = g_list_first(se->ioreq_list); + if (first == NULL) { + DBG("No more pending requests"); + se->ioreq_pending = false; + return -EIO; + } + + req = first->data; + + se->ioreq_list = g_list_remove(se->ioreq_list, req); + + __seel_apdu_dump(__seel_apdu_data(req->apdu), + __seel_apdu_length(req->apdu)); + + err = se->io_driver->transceive(se->ctrl_idx, se->se_idx, + __seel_apdu_data(req->apdu), + __seel_apdu_length(req->apdu), + io_cb, req); + + return err; +} + +int __seel_se_queue_io(struct seel_se *se, struct seel_apdu *apdu, + transceive_cb_t cb, void *context) +{ + struct seel_se_ioreq *req; + + DBG("Pending req %d", se->ioreq_pending); + + req = g_try_malloc0(sizeof(struct seel_se_ioreq)); + if (req == NULL) { + cb(context, NULL, 0, -ENOMEM); + __seel_apdu_free(apdu); + return -ENOMEM; + } + + req->se = se; + req->apdu = apdu; + req->context = context; + req->cb = cb; + + se->ioreq_list = g_list_append(se->ioreq_list, req); + + if (se->ioreq_pending == true) + return 0; + + return send_io(se); +} + +static char *ctrl_to_string(enum seel_controller_type ctrl_type) +{ + switch (ctrl_type) { + case SEEL_CONTROLLER_NFC: + return "nfc"; + case SEEL_CONTROLLER_MODEM: + return "modem"; + case SEEL_CONTROLLER_ASSD: + return "assd"; + case SEEL_CONTROLLER_PCSC: + return "pcsc"; + case SEEL_CONTROLLER_UNKNOWN: + return NULL; + } + + return NULL; +} + +static char *se_to_string(enum seel_se_type se_type) +{ + switch (se_type) { + case SEEL_SE_NFC: + return "eSE"; + case SEEL_SE_ASSD: + return "sdio"; + case SEEL_SE_PCSC: + return "pcsc"; + case SEEL_SE_UICC: + return "uicc"; + case SEEL_SE_UNKNOWN: + return NULL; + } + + return NULL; +} + +static char *se_path(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t se_type, uint8_t ctrl_type) +{ + char *ctrl, *type; + + ctrl = ctrl_to_string(ctrl_type); + if (ctrl == NULL) + return NULL; + + type = se_to_string(se_type); + if (type == NULL) + return NULL; + + return g_strdup_printf("%s/se/%s%d_%s_se%d", SEEL_PATH, + ctrl, ctrl_idx, type, se_idx); +} + +struct seel_se *__seel_se_get(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t ctrl_type) +{ + struct seel_se *se; + GHashTableIter iter; + gpointer key, value; + + g_hash_table_iter_init(&iter, se_hash); + while (g_hash_table_iter_next(&iter, &key, &value)) { + se = value; + + if (se->ctrl_idx == ctrl_idx && + se->se_idx == se_idx && + se->ctrl_type == ctrl_type) + return se; + } + + return NULL; +} + +const char *__seel_se_get_path(struct seel_se *se) +{ + return se->path; +} + +const GSList *__seel_se_get_hashes(struct seel_se *se, const char *owner) +{ + pid_t pid; + + if (se->cert_driver == NULL) + return NULL; + +// pid = g_dbus_get_pid_sync(connection, owner); + pid = 0; + + DBG("app pid %d", pid); + + if (pid < 0) + return NULL; + + return se->cert_driver->get_hashes(pid); +} + +static int se_toggle(struct seel_se *se, bool enable) +{ + DBG(""); + + if (se->ctrl_driver == NULL) { + near_error("No controller driver"); + return -EOPNOTSUPP; + } + + if (enable) + return se->ctrl_driver->enable_se(se->ctrl_idx, se->se_idx); + else + return se->ctrl_driver->disable_se(se->ctrl_idx, se->se_idx); +} + +static void append_channel_path(gpointer key, gpointer value, + gpointer user_data) +{ + struct seel_channel *channel = value; + DBusMessageIter *iter = user_data; + const char *channel_path; + + channel_path = __seel_channel_get_path(channel); + if (!channel_path) + return; + + DBG("%s", channel_path); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, + &channel_path); +} + +static void append_channels(DBusMessageIter *iter, void *user_data) +{ + struct seel_se *se = user_data; + const char *basic_channel_path; + + DBG(""); + + basic_channel_path = __seel_channel_get_path(se->basic_channel); + if (!basic_channel_path) + return; + + DBG("%s", basic_channel_path); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, + &basic_channel_path); + + g_hash_table_foreach(se->channel_hash, append_channel_path, iter); +} + +static DBusMessage *get_properties(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct seel_se *se = data; + DBusMessage *reply; + DBusMessageIter array, dict; + char *se_type = se_to_string(se->se_type); + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append(reply, &array); + + near_dbus_dict_open(&array, &dict); + + near_dbus_dict_append_basic(&dict, "Enabled", + DBUS_TYPE_BOOLEAN, &se->enabled); + + near_dbus_dict_append_basic(&dict, "Type", + DBUS_TYPE_STRING, &se_type); + + near_dbus_dict_append_array(&dict, "Channels", + DBUS_TYPE_OBJECT_PATH, append_channels, se); + + near_dbus_dict_close(&array, &dict); + + return reply; +} + +static DBusMessage *set_property(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct seel_se *se = data; + DBusMessageIter iter, value; + const char *name; + int type, err; + + DBG("conn %p", conn); + + if (dbus_message_iter_init(msg, &iter) == FALSE) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &name); + dbus_message_iter_next(&iter); + dbus_message_iter_recurse(&iter, &value); + + type = dbus_message_iter_get_arg_type(&value); + + if (g_str_equal(name, "Enabled") == TRUE) { + bool enabled; + + if (type != DBUS_TYPE_BOOLEAN) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&value, &enabled); + + err = se_toggle(se, enabled); + if (err < 0) { + if (err == -EALREADY) { + if (enabled) + return __near_error_already_enabled(msg); + else + return __near_error_already_disabled(msg); + } + + return __near_error_failed(msg, -err); + } + + se->enabled = enabled; + } else { + return __near_error_invalid_property(msg); + } + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +struct open_channel_context { + DBusMessage *msg; + struct seel_se *se; + unsigned char *aid; + int aid_len; + uint8_t channel; +}; + +static void open_channel_error(struct open_channel_context *ctx, int err) +{ + DBusMessage *reply; + DBusConnection *conn; + + near_error("error %d", err); + + conn = near_dbus_get_connection(); + + reply = __near_error_failed(ctx->msg, -err); + if (reply != NULL) + g_dbus_send_message(conn, reply); + + dbus_message_unref(ctx->msg); + ctx->msg = NULL; + g_free(ctx); +} + +static void select_aid_cb(void *context, + uint8_t *apdu, size_t apdu_length, + int err) +{ + struct open_channel_context *ctx = context; + struct seel_channel *channel; + char *path; + DBusConnection *conn; + + conn = near_dbus_get_connection(); + + if (err != 0) + return open_channel_error(ctx, err); + + channel = __seel_channel_add(ctx->se, ctx->channel, + ctx->aid, ctx->aid_len, false); + if (!channel) + return open_channel_error(ctx, -ENOMEM); + + path = __seel_channel_get_path(channel); + g_hash_table_replace(ctx->se->channel_hash, path, channel); + + g_dbus_send_reply(conn, ctx->msg, + DBUS_TYPE_OBJECT_PATH, &path, + DBUS_TYPE_INVALID); + + dbus_message_unref(ctx->msg); + ctx->msg = NULL; + g_free(ctx); +} + +static void open_channel_cb(void *context, + uint8_t *apdu, size_t apdu_length, + int err) +{ + struct open_channel_context *ctx = context; + struct seel_apdu *select_aid; + + DBG(""); + + if (err || !apdu) + return open_channel_error(ctx, err); + + /* Check response status */ + err = __seel_apdu_resp_status(apdu, apdu_length); + if (err) { + DBG("err %d", err); + return open_channel_error(ctx, err); + } + + ctx->channel = apdu[0]; + + DBG("Channel %d", ctx->channel); + + select_aid = __seel_apdu_select_aid(ctx->channel, + ctx->aid, ctx->aid_len); + + /* Send the AID selection APDU */ + err = __seel_se_queue_io(ctx->se, select_aid, select_aid_cb, ctx); + if (err < 0) { + near_error("AID err %d", err); + return; + } + + return; +} + +static DBusMessage *open_channel(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct seel_se *se = data; + unsigned char *aid; + int aid_len, err; + struct open_channel_context *ctx; + struct seel_apdu *open_channel; + + DBG(""); + + if (se->enabled == false) + return __near_error_failed(msg, ENODEV); + + if (!dbus_message_get_args(msg, NULL, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &aid, &aid_len, DBUS_TYPE_INVALID)) + return __near_error_invalid_arguments(msg); + + ctx = g_try_malloc0(sizeof(struct open_channel_context)); + if (ctx == NULL) + return __near_error_failed(msg, ENOMEM); + + open_channel = __seel_apdu_open_logical_channel(); + if (open_channel == NULL) { + g_free(ctx); + return __near_error_failed(msg, ENOMEM); + } + + ctx->msg = dbus_message_ref(msg); + ctx->se = se; + ctx->aid = aid; + ctx->aid_len = aid_len; + + err = __seel_se_queue_io(se, open_channel, open_channel_cb, ctx); + if (err < 0) { + near_error("open channel error %d", err); + return NULL; + } + + return NULL; +} + +struct close_channel_context { + DBusMessage *msg; + struct seel_se *se; + struct seel_channel *channel; + uint8_t chn; +}; + +static void close_channel_error(struct close_channel_context *ctx, int err) +{ + DBusMessage *reply; + DBusConnection *conn; + + near_error("error %d", err); + + conn = near_dbus_get_connection(); + + reply = __near_error_failed(ctx->msg, -err); + if (reply != NULL) + g_dbus_send_message(conn, reply); + + dbus_message_unref(ctx->msg); + ctx->msg = NULL; + g_free(ctx); +} + +static void close_channel_cb(void *context, uint8_t *apdu, size_t apdu_length, + int err) +{ + struct close_channel_context *ctx = context; + char *channel_path; + DBusConnection *conn; + + conn = near_dbus_get_connection(); + + if (err) + return close_channel_error(ctx, err); + + /* Check response status */ + err = __seel_apdu_resp_status(apdu, apdu_length); + if (err) + return close_channel_error(ctx, err); + + channel_path = __seel_channel_get_path(ctx->channel); + if (!g_hash_table_remove(ctx->se->channel_hash, channel_path)) + return close_channel_error(ctx, -ENODEV); + + g_dbus_send_reply(conn, ctx->msg, DBUS_TYPE_INVALID); + + dbus_message_unref(ctx->msg); + ctx->msg = NULL; + g_free(ctx); + + return; +} + +static DBusMessage *close_channel(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct seel_se *se = data; + const char *path; + int err; + struct close_channel_context *ctx; + struct seel_apdu *close_channel; + + if (se->enabled == false) + return __near_error_failed(msg, ENODEV); + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, + DBUS_TYPE_INVALID)) + return __near_error_invalid_arguments(msg); + + ctx = g_try_malloc0(sizeof(struct open_channel_context)); + if (ctx == NULL) + return __near_error_failed(msg, ENOMEM); + + ctx->channel = g_hash_table_lookup(se->channel_hash, path); + if (!ctx->channel) { + g_free(ctx); + return __near_error_invalid_arguments(msg); + } + + ctx->se = se; + ctx->chn = __seel_channel_get_channel(ctx->channel); + + close_channel = __seel_apdu_close_logical_channel(ctx->chn); + if (!close_channel) { + g_free(ctx); + return __near_error_failed(msg, ENOMEM); + } + + ctx->msg = dbus_message_ref(msg); + + err = __seel_se_queue_io(se, close_channel, close_channel_cb, ctx); + if (err < 0) { + near_error("close channel error %d", err); + return NULL; + } + + return NULL; +} + +static const GDBusMethodTable se_methods[] = { + { GDBUS_METHOD("GetProperties", + NULL, GDBUS_ARGS({"properties", "a{sv}"}), + get_properties) }, + { GDBUS_METHOD("SetProperty", + GDBUS_ARGS({"name", "s"}, {"value", "v"}), + NULL, set_property) }, + { GDBUS_ASYNC_METHOD("OpenChannel", + GDBUS_ARGS({"aid", "ay"}), + GDBUS_ARGS({"channel", "o"}), + open_channel) }, + { GDBUS_ASYNC_METHOD("CloseChannel", + GDBUS_ARGS({"channel", "o"}), + NULL, close_channel) }, + { }, +}; + +static const GDBusSignalTable se_signals[] = { + { GDBUS_SIGNAL("PropertyChanged", + GDBUS_ARGS({"name", "s"}, {"value", "v"})) }, + { } +}; + +char *__seel_se_add(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t se_type, uint8_t ctrl_type) +{ + struct seel_se *se; + + se = g_try_malloc0(sizeof(struct seel_se)); + if (se == NULL) + return NULL; + + se->path = se_path(se_idx, ctrl_idx, se_type, ctrl_type); + if (se->path == NULL) + return NULL; + + se->ctrl_idx = ctrl_idx; + se->se_idx = se_idx; + se->se_type = se_type; + se->ctrl_type = ctrl_type; + se->ctrl_driver = __seel_driver_ctrl_find(ctrl_type); + se->io_driver = __seel_driver_io_find(se_type); + se->ioreq_pending = false; + se->cert_driver = __seel_driver_cert_get(); + se->basic_channel = __seel_channel_add(se, 0, NULL, 0, true); + se->channel_hash = g_hash_table_new_full(g_str_hash, g_str_equal, + NULL, se_channel_free); + se->enabled = false; + + g_hash_table_replace(se_hash, se->path, se); + + g_dbus_register_interface(connection, se->path, + SEEL_SE_INTERFACE, + se_methods, se_signals, + NULL, se, NULL); + + g_idle_add(__seel_ace_add, se); + + return se->path; +} + +int __seel_se_remove(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t ctrl_type) +{ + struct seel_se *se; + + se = __seel_se_get(se_idx, ctrl_idx, ctrl_type); + if (se == NULL) + return -ENODEV; + + __seel_ace_remove(se); + + __seel_channel_remove(se->basic_channel); + g_hash_table_destroy(se->channel_hash); + + g_dbus_unregister_interface(connection, se->path, + SEEL_SE_INTERFACE); + + if (!g_hash_table_remove(se_hash, se->path)) + return -ENODEV; + + return 0; +} + +int __seel_se_init(DBusConnection *conn) +{ + DBG(""); + + connection = dbus_connection_ref(conn); + + se_hash = g_hash_table_new_full(g_str_hash, g_str_equal, + NULL, se_free); + + return 0; +} + +void __seel_se_cleanup(void) +{ + DBG(""); + + dbus_connection_unref(connection); + + g_hash_table_destroy(se_hash); + se_hash = NULL; +}
diff --git a/neard/se/se.h b/neard/se/se.h new file mode 100644 index 0000000..6e2e6f9 --- /dev/null +++ b/neard/se/se.h
@@ -0,0 +1,37 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifndef __SEEL_SE_H +#define __SEEL_SE_H + +enum seel_controller_type { + SEEL_CONTROLLER_NFC = 0, + SEEL_CONTROLLER_MODEM, + SEEL_CONTROLLER_ASSD, + SEEL_CONTROLLER_PCSC, + SEEL_CONTROLLER_UNKNOWN = 0xff +}; + +enum seel_se_type { + SEEL_SE_NFC = 0, /* Embedded SE on NFC */ + SEEL_SE_ASSD, /* Advanced Security SD SE */ + SEEL_SE_PCSC, /* PCSC compatible SE */ + SEEL_SE_UICC, /* SIM card SE */ + SEEL_SE_UNKNOWN = 0xff +}; + +#endif
diff --git a/neard/se/seel.h b/neard/se/seel.h new file mode 100644 index 0000000..1e46f3c --- /dev/null +++ b/neard/se/seel.h
@@ -0,0 +1,85 @@ +/* + * + * seeld - Secure Element Manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#include <stdint.h> +#include <stdbool.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <glib.h> + +#include "../src/near.h" + +struct seel_se; +struct seel_channel; +struct seel_ace; +struct seel_apdu *apdu; + +int __seel_manager_init(DBusConnection *conn); +void __seel_manager_cleanup(void); + +#include "driver.h" + +struct seel_ctrl_driver *__seel_driver_ctrl_find(enum seel_controller_type type); +struct seel_io_driver *__seel_driver_io_find(enum seel_se_type type); +struct seel_cert_driver *__seel_driver_cert_get(void); + +struct seel_se *__seel_se_get(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t ctrl_type); +const char *__seel_se_get_path(struct seel_se *se); +const GSList *__seel_se_get_hashes(struct seel_se *se, const char *owner); +int __seel_se_queue_io(struct seel_se *se, struct seel_apdu *apdu, + transceive_cb_t cb, void *context); +void __seel_se_list(DBusMessageIter *iter, void *user_data); +char *__seel_se_add(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t se_type, uint8_t ctrl_type); +int __seel_se_remove(uint32_t se_idx, uint8_t ctrl_idx, + uint8_t ctrl_type); +int __seel_se_init(DBusConnection *conn); +void __seel_se_cleanup(void); + +struct seel_apdu *__seel_apdu_build(uint8_t *apdu, size_t length, uint8_t channel); +void __seel_apdu_dump(uint8_t *apdu, size_t length); +void __seel_apdu_free(struct seel_apdu *apdu); +size_t __seel_apdu_length(struct seel_apdu *apdu); +uint8_t *__seel_apdu_data(struct seel_apdu *apdu); +struct seel_apdu *__seel_apdu_open_logical_channel(void); +struct seel_apdu *__seel_apdu_close_logical_channel(uint8_t channel); +struct seel_apdu *__seel_apdu_select_aid(uint8_t channel, uint8_t *aid, size_t aid_length); +struct seel_apdu *__seel_apdu_get_all_gp_data(void); +struct seel_apdu *__seel_apdu_get_next_gp_data(size_t length); +struct seel_apdu *__seel_apdu_get_refresh_gp_data(void); +int __seel_apdu_resp_status(uint8_t *apdu, size_t apdu_length); + +struct seel_channel *__seel_channel_add(struct seel_se *se, + uint8_t channel, + unsigned char *aid, size_t aid_len, + bool basic); +void __seel_channel_remove(struct seel_channel *channel); +char *__seel_channel_get_path(struct seel_channel *channel); +uint8_t __seel_channel_get_channel(struct seel_channel *channel); +uint8_t *__seel_channel_get_aid(struct seel_channel *channel, size_t *aid_len); +struct seel_se *__seel_channel_get_se(struct seel_channel *channel); +bool __seel_channel_is_basic(struct seel_channel *channel); + +gboolean __seel_ace_add(gpointer user_data); +int __seel_ace_remove(struct seel_se *se); +bool __seel_ace_apdu_allowed(struct seel_channel *channel, uint8_t *app_hash, + uint8_t *apdu, size_t apdu_len); +int __seel_ace_init(void); +void __seel_ace_cleanup(void);
diff --git a/neard/se/seeld.pc.in b/neard/se/seeld.pc.in new file mode 100644 index 0000000..a8e7b80 --- /dev/null +++ b/neard/se/seeld.pc.in
@@ -0,0 +1,13 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +plugindir=${libdir}/seeld/plugins + +Name: seeld +Description: Secure Element daemon +Requires: @GLIB_DEPS@ @DBUS_DEPS@ +Version: @VERSION@ +Libs: -module -avoid-version -export-symbols-regex seeld_plugin_desc +Cflags: -I${includedir}
diff --git a/neard/src/adapter.c b/neard/src/adapter.c new file mode 100644 index 0000000..4585409 --- /dev/null +++ b/neard/src/adapter.c
@@ -0,0 +1,1208 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "near.h" + +/* We check for the tag being present every 2 seconds */ +#define CHECK_PRESENCE_PERIOD 2 + +static DBusConnection *connection = NULL; + +static GHashTable *adapter_hash; + +enum near_adapter_rf_mode { + NEAR_ADAPTER_RF_MODE_IDLE = 0, + NEAR_ADAPTER_RF_MODE_INITIATOR = 1, + NEAR_ADAPTER_RF_MODE_TARGET = 2 +}; + +#define NEAR_ADAPTER_MODE_INITIATOR 0x1 +#define NEAR_ADAPTER_MODE_TARGET 0x2 +#define NEAR_ADAPTER_MODE_DUAL 0x3 + +struct near_adapter { + char *path; + + char *name; + uint32_t idx; + uint32_t protocols; + uint32_t poll_mode; + enum near_adapter_rf_mode rf_mode; + + bool powered; + bool polling; + bool constant_poll; + bool dep_up; + + GHashTable *tags; + struct near_tag *tag_link; + int tag_sock; + + GHashTable *devices; + struct near_device *device_link; + int device_sock; + + GIOChannel *channel; + guint watch; + GList *ioreq_list; + + guint presence_timeout; + guint dep_timer; +}; + +struct near_adapter_ioreq { + uint32_t target_idx; + near_recv cb; + unsigned char buf[1024]; + size_t len; + void *data; +}; + +/* HACK HACK */ +#ifndef AF_NFC +#define AF_NFC 39 +#endif + +static void free_adapter(gpointer data) +{ + struct near_adapter *adapter = data; + + if (adapter->presence_timeout > 0) + g_source_remove(adapter->presence_timeout); + + if (adapter->dep_timer > 0) + g_source_remove(adapter->dep_timer); + + g_free(adapter->name); + g_free(adapter->path); + g_hash_table_destroy(adapter->tags); + g_hash_table_destroy(adapter->devices); + g_free(adapter); +} + +static void free_tag(gpointer data) +{ + struct near_tag *tag = data; + + __near_tag_remove(tag); +} + +static void free_device(gpointer data) +{ + struct near_device *device = data; + + __near_device_remove(device); +} + +static char *rf_mode_to_string(struct near_adapter *adapter) +{ + switch (adapter->rf_mode) { + case NEAR_ADAPTER_RF_MODE_IDLE: + return "Idle"; + case NEAR_ADAPTER_RF_MODE_INITIATOR: + return "Initiator"; + case NEAR_ADAPTER_RF_MODE_TARGET: + return "Target"; + } + + return NULL; +} + +static void polling_changed(struct near_adapter *adapter) +{ + g_dbus_emit_property_changed(connection, adapter->path, + NFC_ADAPTER_INTERFACE, "Polling"); +} + +static void rf_mode_changed(struct near_adapter *adapter) +{ + g_dbus_emit_property_changed(connection, adapter->path, + NFC_ADAPTER_INTERFACE, "Mode"); +} + +static int adapter_start_poll(struct near_adapter *adapter) +{ + int err; + uint32_t im_protos, tm_protos; + + if (g_hash_table_size(adapter->tags) > 0) { + DBG("Clearing tags"); + + g_hash_table_remove_all(adapter->tags); + } + + if (g_hash_table_size(adapter->devices) > 0) { + DBG("Clearing devices"); + + g_hash_table_remove_all(adapter->devices); + } + + DBG("Poll mode 0x%x", adapter->poll_mode); + + im_protos = tm_protos = 0; + + if (adapter->poll_mode & NEAR_ADAPTER_MODE_INITIATOR) + im_protos = adapter->protocols; + + if (adapter->poll_mode & NEAR_ADAPTER_MODE_TARGET) + tm_protos = adapter->protocols; + + err = __near_netlink_start_poll(adapter->idx, im_protos, tm_protos); + if (err < 0) + return err; + + adapter->polling = true; + + polling_changed(adapter); + + return 0; +} + +static gboolean property_get_mode(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_adapter *adapter = user_data; + const char *rf_mode; + + rf_mode = rf_mode_to_string(adapter); + if (!rf_mode) + return FALSE; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &rf_mode); + + return TRUE; +} + +static gboolean property_get_polling(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_adapter *adapter = user_data; + dbus_bool_t val; + + val = adapter->polling; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val); + + return TRUE; +} + +static gboolean property_get_powered(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_adapter *adapter = user_data; + dbus_bool_t val; + + val = adapter->powered; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val); + + return TRUE; +} + +static void set_powered(GDBusPendingPropertySet id, dbus_bool_t powered, + void *data) +{ + struct near_adapter *adapter = data; + int err; + + err = __near_netlink_adapter_enable(adapter->idx, powered); + if (err < 0) { + if (err == -EALREADY) { + if (powered) + g_dbus_pending_property_error(id, + NFC_ERROR_INTERFACE ".Failed", + "Device already enabled"); + else + g_dbus_pending_property_error(id, + NFC_ERROR_INTERFACE ".Failed", + "Device already disabled"); + } + + g_dbus_pending_property_error(id, + NFC_ERROR_INTERFACE ".Failed", + strerror(err)); + + return; + } + + g_dbus_pending_property_success(id); + + adapter->powered = powered; + + g_dbus_emit_property_changed(connection, adapter->path, + NFC_ADAPTER_INTERFACE, "Powered"); +} + +static void property_set_powered(const GDBusPropertyTable *property, + DBusMessageIter *value, + GDBusPendingPropertySet id, void *data) +{ + dbus_bool_t powered; + + if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN) { + g_dbus_pending_property_error(id, + NFC_ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); + return; + } + + dbus_message_iter_get_basic(value, &powered); + + set_powered(id, powered, data); +} + +static void append_protocols(DBusMessageIter *iter, + struct near_adapter *adapter) +{ + const char *str; + + DBG("protocols 0x%x", adapter->protocols); + + if (adapter->protocols & NFC_PROTO_FELICA_MASK) { + str = "Felica"; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str); + } + + if (adapter->protocols & NFC_PROTO_MIFARE_MASK) { + str = "MIFARE"; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str); + } + + if (adapter->protocols & NFC_PROTO_JEWEL_MASK) { + str = "Jewel"; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str); + } + + if ((adapter->protocols & NFC_PROTO_ISO14443_MASK) || + (adapter->protocols & NFC_PROTO_ISO14443_B_MASK)) { + str = "ISO-DEP"; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str); + } + + if (adapter->protocols & NFC_PROTO_NFC_DEP_MASK) { + str = "NFC-DEP"; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str); + } + + if (adapter->protocols & NFC_PROTO_ISO15693_MASK) { + str = "ISO-15693"; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str); + } +} + +static gboolean property_get_protocols(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_adapter *adapter = user_data; + DBusMessageIter dict; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &dict); + + append_protocols(&dict, adapter); + + dbus_message_iter_close_container(iter, &dict); + + return TRUE; +} + +static DBusMessage *start_poll_loop(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct near_adapter *adapter = data; + const char *dbus_mode; + int err; + + DBG("conn %p", conn); + + if (!adapter->powered) { + near_error("Adapter is down, can not start polling"); + return __near_error_failed(msg, ENODEV); + } + + dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &dbus_mode, + DBUS_TYPE_INVALID); + + DBG("Mode %s", dbus_mode); + + if (g_strcmp0(dbus_mode, "Initiator") == 0) + adapter->poll_mode = NEAR_ADAPTER_MODE_INITIATOR; + else if (g_strcmp0(dbus_mode, "Target") == 0) + adapter->poll_mode = NEAR_ADAPTER_MODE_TARGET; + else if (g_strcmp0(dbus_mode, "Dual") == 0) + adapter->poll_mode = NEAR_ADAPTER_MODE_DUAL; + else + adapter->poll_mode = NEAR_ADAPTER_MODE_INITIATOR; + + err = adapter_start_poll(adapter); + if (err < 0) + return __near_error_failed(msg, -err); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static DBusMessage *stop_poll_loop(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct near_adapter *adapter = data; + int err; + + DBG("conn %p", conn); + + if (!adapter->polling) + return __near_error_not_polling(msg); + + err = __near_netlink_stop_poll(adapter->idx); + if (err < 0) + return __near_error_failed(msg, -err); + + adapter->polling = false; + + polling_changed(adapter); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static void tag_present_cb(uint32_t adapter_idx, uint32_t target_idx, + int status); + +static gboolean check_presence(gpointer user_data) +{ + struct near_adapter *adapter = user_data; + struct near_tag *tag; + int err; + + DBG(""); + + if (!adapter) + return FALSE; + + tag = adapter->tag_link; + if (!tag) + goto out_err; + + err = __near_tag_check_presence(tag, tag_present_cb); + if (err < 0) { + DBG("Could not check target presence"); + goto out_err; + } + + return FALSE; + +out_err: + near_adapter_disconnect(adapter->idx); + if (adapter->constant_poll) + adapter_start_poll(adapter); + + return FALSE; +} + +static gboolean dep_timer(gpointer user_data) +{ + struct near_adapter *adapter = user_data; + + DBG(""); + + if (!adapter) + return FALSE; + + adapter_start_poll(adapter); + + return FALSE; +} + +static void tag_present_cb(uint32_t adapter_idx, uint32_t target_idx, + int status) +{ + struct near_adapter *adapter; + + DBG(""); + + adapter = g_hash_table_lookup(adapter_hash, + GINT_TO_POINTER(adapter_idx)); + if (!adapter) + return; + + if (status < 0) { + DBG("Tag is gone"); + + near_adapter_disconnect(adapter->idx); + if (adapter->constant_poll) + adapter_start_poll(adapter); + + return; + } + + adapter->presence_timeout = + g_timeout_add_seconds(CHECK_PRESENCE_PERIOD, + check_presence, adapter); +} + +void __near_adapter_start_check_presence(uint32_t adapter_idx, + uint32_t target_idx) +{ + struct near_adapter *adapter; + + DBG(""); + + adapter = g_hash_table_lookup(adapter_hash, + GINT_TO_POINTER(adapter_idx)); + if (!adapter) + return; + + adapter->presence_timeout = + g_timeout_add_seconds(CHECK_PRESENCE_PERIOD, + check_presence, adapter); +} + +void __near_adapter_stop_check_presence(uint32_t adapter_idx, + uint32_t target_idx) +{ + struct near_adapter *adapter; + + DBG(""); + + adapter = g_hash_table_lookup(adapter_hash, + GINT_TO_POINTER(adapter_idx)); + if (!adapter) + return; + + if (adapter->presence_timeout > 0) + g_source_remove(adapter->presence_timeout); +} + +static const GDBusMethodTable adapter_methods[] = { + { GDBUS_METHOD("StartPollLoop", GDBUS_ARGS({"name", "s"}), NULL, + start_poll_loop) }, + { GDBUS_METHOD("StopPollLoop", NULL, NULL, stop_poll_loop) }, + { }, +}; + +static const GDBusPropertyTable adapter_properties[] = { + { "Mode", "s", property_get_mode }, + { "Powered", "b", property_get_powered, property_set_powered }, + { "Polling", "b", property_get_polling }, + { "Protocols", "as", property_get_protocols }, + + { } +}; + +struct near_adapter *__near_adapter_create(uint32_t idx, + const char *name, uint32_t protocols, bool powered) +{ + struct near_adapter *adapter; + bool powered_setting; + + adapter = g_try_malloc0(sizeof(struct near_adapter)); + if (!adapter) + return NULL; + + adapter->name = g_strdup(name); + if (!adapter->name) { + g_free(adapter); + return NULL; + } + + powered_setting = near_setting_get_bool("DefaultPowered"); + if (powered_setting && !powered && + !__near_netlink_adapter_enable(idx, powered_setting)) + powered = true; + + DBG("Powered %d", powered); + + adapter->idx = idx; + adapter->protocols = protocols; + adapter->powered = powered; + adapter->constant_poll = near_setting_get_bool("ConstantPoll"); + adapter->dep_up = false; + adapter->tags = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, free_tag); + adapter->tag_sock = -1; + + adapter->devices = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, free_device); + adapter->device_sock = -1; + + adapter->path = g_strdup_printf("%s/nfc%d", NFC_PATH, idx); + + return adapter; +} + +void __near_adapter_destroy(struct near_adapter *adapter) +{ + DBG(""); + + free_adapter(adapter); +} + +const char *__near_adapter_get_path(struct near_adapter *adapter) +{ + return adapter->path; +} + +struct near_adapter *__near_adapter_get(uint32_t idx) +{ + return g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); +} + +int __near_adapter_set_dep_state(uint32_t idx, bool dep) +{ + struct near_adapter *adapter; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return -ENODEV; + + adapter->dep_up = dep; + + if (!dep && adapter->constant_poll) { + /* + * The immediate polling may fail if the adapter is busy in + * that very moment. In this case we need to try polling later + * again, so constant polling will work properly. + */ + if(adapter_start_poll(adapter) == -EBUSY) { + near_error("Adapter is busy, retry polling later"); + g_timeout_add_seconds(1, dep_timer, adapter); + } + } + + if (!dep) { + uint32_t target_idx; + + target_idx = __neard_device_get_idx(adapter->device_link); + __near_adapter_remove_target(idx, target_idx); + } else { + if (adapter->dep_timer > 0) + g_source_remove(adapter->dep_timer); + + if (!__near_device_register_interface(adapter->device_link)) + return -ENODEV; + } + + return 0; +} + +bool __near_adapter_get_dep_state(uint32_t idx) +{ + struct near_adapter *adapter; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return false; + + return adapter->dep_up; +} + +int __near_adapter_add(struct near_adapter *adapter) +{ + uint32_t idx = adapter->idx; + + DBG("%s", adapter->path); + + if (g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx))) + return -EEXIST; + + g_hash_table_insert(adapter_hash, GINT_TO_POINTER(idx), adapter); + + DBG("connection %p", connection); + + g_dbus_register_interface(connection, adapter->path, + NFC_ADAPTER_INTERFACE, + adapter_methods, NULL, + adapter_properties, adapter, NULL); + + return 0; +} + +void __near_adapter_remove(struct near_adapter *adapter) +{ + DBG("%s", adapter->path); + + g_dbus_unregister_interface(connection, adapter->path, + NFC_ADAPTER_INTERFACE); + + g_hash_table_remove(adapter_hash, GINT_TO_POINTER(adapter->idx)); +} + +static void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status) +{ + struct near_adapter *adapter; + + DBG("status %d", status); + + adapter = g_hash_table_lookup(adapter_hash, + GINT_TO_POINTER(adapter_idx)); + if (!adapter) + return; + + if (status < 0) { + near_adapter_disconnect(adapter->idx); + if (adapter->constant_poll) + adapter_start_poll(adapter); + + return; + } + + adapter->presence_timeout = + g_timeout_add_seconds(CHECK_PRESENCE_PERIOD, + check_presence, adapter); +} + +static void device_read_cb(uint32_t adapter_idx, uint32_t target_idx, + int status) +{ + struct near_adapter *adapter; + + DBG("status %d", status); + + adapter = g_hash_table_lookup(adapter_hash, + GINT_TO_POINTER(adapter_idx)); + if (!adapter) + return; + + if (status < 0) { + if (adapter->device_link) { + __near_netlink_dep_link_down(adapter->idx); + adapter->device_link = NULL; + } + + if (adapter->constant_poll) + adapter_start_poll(adapter); + + return; + } +} + +static int adapter_add_tag(struct near_adapter *adapter, uint32_t target_idx, + uint32_t protocols, + uint16_t sens_res, uint8_t sel_res, + uint8_t *nfcid, uint8_t nfcid_len, + uint8_t iso15693_dsfid, + uint8_t iso15693_uid_len, uint8_t *iso15693_uid) +{ + struct near_tag *tag; + uint32_t tag_type; + int err; + + tag = __near_tag_add(adapter->idx, target_idx, protocols, + sens_res, sel_res, + nfcid, nfcid_len, + iso15693_dsfid, iso15693_uid_len, iso15693_uid); + if (!tag) + return -ENODEV; + + g_hash_table_insert(adapter->tags, GINT_TO_POINTER(target_idx), tag); + + tag_type = __near_tag_get_type(tag); + + err = near_adapter_connect(adapter->idx, target_idx, tag_type); + if (err < 0) { + near_error("Could not connect"); + return err; + } + + err = __near_tag_read(tag, tag_read_cb); + if (err < 0) { + near_error("Could not read the tag"); + + near_adapter_disconnect(adapter->idx); + __near_adapter_remove_target(adapter->idx, target_idx); + } + + return err; +} + +static int adapter_add_device(struct near_adapter *adapter, + uint32_t target_idx, + uint8_t *nfcid, uint8_t nfcid_len) +{ + struct near_device *device; + int err; + + DBG(); + + device = __near_device_add(adapter->idx, target_idx, nfcid, nfcid_len); + if (!device) + return -ENODEV; + + g_hash_table_insert(adapter->devices, GINT_TO_POINTER(target_idx), + device); + + /* For p2p, reading is listening for an incoming connection */ + err = __near_device_listen(device, device_read_cb); + if (err < 0) { + near_error("Could not read device"); + return err; + } + + adapter->device_link = device; + + if (adapter->dep_up) { + if (!__near_device_register_interface(device)) + return -ENODEV; + + return 0; + } + + err = __near_netlink_dep_link_up(adapter->idx, target_idx, + NFC_COMM_ACTIVE, NFC_RF_INITIATOR); + + if (err < 0) + adapter->device_link = NULL; + + DBG("Starting DEP timer"); + + adapter->dep_timer = g_timeout_add_seconds(1, dep_timer, adapter); + + return err; +} + +int __near_adapter_add_target(uint32_t idx, uint32_t target_idx, + uint32_t protocols, uint16_t sens_res, uint8_t sel_res, + uint8_t *nfcid, uint8_t nfcid_len, + uint8_t iso15693_dsfid, + uint8_t iso15693_uid_len, uint8_t *iso15693_uid) +{ + struct near_adapter *adapter; + int ret; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return -ENODEV; + + adapter->polling = false; + polling_changed(adapter); + + adapter->rf_mode = NEAR_ADAPTER_RF_MODE_INITIATOR; + rf_mode_changed(adapter); + + if (protocols & NFC_PROTO_NFC_DEP_MASK) + ret = adapter_add_device(adapter, target_idx, + nfcid, nfcid_len); + else + ret = adapter_add_tag(adapter, target_idx, protocols, + sens_res, sel_res, nfcid, nfcid_len, + iso15693_dsfid, + iso15693_uid_len, iso15693_uid); + + if (ret < 0 && adapter->constant_poll) + adapter_start_poll(adapter); + + return ret; +} + +int __near_adapter_remove_target(uint32_t idx, uint32_t target_idx) +{ + struct near_adapter *adapter; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return -ENODEV; + + adapter->rf_mode = NEAR_ADAPTER_RF_MODE_IDLE; + rf_mode_changed(adapter); + + if (g_hash_table_remove(adapter->tags, GINT_TO_POINTER(target_idx))) + return 0; + + if (g_hash_table_remove(adapter->devices, GINT_TO_POINTER(target_idx))) + return 0; + + return 0; +} + +static gboolean poll_error(gpointer user_data) +{ + struct near_adapter *adapter = user_data; + bool reset; + + DBG("adapter %d", adapter->idx); + + reset = near_setting_get_bool("ResetOnError"); + if (reset) { + near_error("Resetting nfc%d", adapter->idx); + __near_netlink_adapter_enable(adapter->idx, false); + __near_netlink_adapter_enable(adapter->idx, true); + } + + adapter_start_poll(adapter); + + return FALSE; +} + +int __near_adapter_get_targets_done(uint32_t idx) +{ + struct near_adapter *adapter; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return -ENODEV; + + if (g_hash_table_size(adapter->devices) > 0) + return 0; + + if (g_hash_table_size(adapter->tags) > 0) + return 0; + + near_error("No targets found - Polling error"); + + adapter->polling = false; + polling_changed(adapter); + + g_idle_add(poll_error, adapter); + + return 0; +} + +int __near_adapter_add_device(uint32_t idx, uint8_t *nfcid, uint8_t nfcid_len) +{ + struct near_adapter *adapter; + int ret; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return -ENODEV; + + adapter->polling = false; + adapter->dep_up = true; + adapter->rf_mode = NEAR_ADAPTER_RF_MODE_TARGET; + polling_changed(adapter); + rf_mode_changed(adapter); + + ret = adapter_add_device(adapter, 0, nfcid, nfcid_len); + if (ret < 0) + return ret; + + return 0; +} + +int __near_adapter_remove_device(uint32_t idx) +{ + struct near_adapter *adapter; + uint32_t device_idx = 0; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return -ENODEV; + + if (!g_hash_table_remove(adapter->devices, GINT_TO_POINTER(device_idx))) + return 0; + + adapter->rf_mode = NEAR_ADAPTER_RF_MODE_IDLE; + rf_mode_changed(adapter); + + adapter->dep_up = false; + + if (adapter->constant_poll) + adapter_start_poll(adapter); + + return 0; +} + +static void adapter_flush_rx(struct near_adapter *adapter, int error) +{ + GList *list; + + for (list = adapter->ioreq_list; list; list = list->next) { + struct near_adapter_ioreq *req = list->data; + + if (!req) + continue; + + req->cb(NULL, error, req->data); + g_free(req); + } + + g_list_free(adapter->ioreq_list); + adapter->ioreq_list = NULL; +} + +static gboolean execute_recv_cb(gpointer user_data) +{ + struct near_adapter_ioreq *req = user_data; + + DBG("data %p", req->data); + + req->cb(req->buf, req->len, req->data); + + g_free(req); + + return FALSE; +} + +static gboolean adapter_recv_event(GIOChannel *channel, GIOCondition condition, + gpointer user_data) +{ + struct near_adapter *adapter = user_data; + struct near_adapter_ioreq *req; + GList *first; + int sk; + + DBG("condition 0x%x", condition); + + if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { + near_error("Error while reading NFC bytes"); + + adapter_flush_rx(adapter, -EIO); + + near_adapter_disconnect(adapter->idx); + + return FALSE; + } + + sk = g_io_channel_unix_get_fd(channel); + first = g_list_first(adapter->ioreq_list); + if (!first) + return TRUE; + + req = first->data; + req->len = recv(sk, req->buf, sizeof(req->buf), 0); + + adapter->ioreq_list = g_list_remove(adapter->ioreq_list, req); + + g_idle_add(execute_recv_cb, req); + + return TRUE; +} + +int near_adapter_connect(uint32_t idx, uint32_t target_idx, uint8_t protocol) +{ + struct near_adapter *adapter; + struct near_tag *tag; + struct sockaddr_nfc addr; + int err, sock; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return -ENODEV; + + if (adapter->tag_sock != -1) + return -EALREADY; + + tag = g_hash_table_lookup(adapter->tags, + GINT_TO_POINTER(target_idx)); + if (!tag) + return -ENOLINK; + + sock = socket(AF_NFC, SOCK_SEQPACKET, NFC_SOCKPROTO_RAW); + if (sock == -1) + return sock; + + addr.sa_family = AF_NFC; + addr.dev_idx = idx; + addr.target_idx = target_idx; + addr.nfc_protocol = protocol; + + err = connect(sock, (struct sockaddr *) &addr, sizeof(addr)); + if (err) { + close(sock); + return err; + } + + adapter->tag_sock = sock; + adapter->tag_link = tag; + + if (!adapter->channel) + adapter->channel = g_io_channel_unix_new(adapter->tag_sock); + + g_io_channel_set_flags(adapter->channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_channel_set_close_on_unref(adapter->channel, TRUE); + + if (adapter->watch == 0) + adapter->watch = g_io_add_watch(adapter->channel, + G_IO_IN | G_IO_NVAL | G_IO_ERR | G_IO_HUP, + adapter_recv_event, adapter); + + return 0; +} + +int near_adapter_disconnect(uint32_t idx) +{ + struct near_adapter *adapter; + uint32_t target_idx; + uint16_t tag_type; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) + return -ENODEV; + + DBG("link %p", adapter->tag_link); + + if (!adapter->tag_link) + return -ENOLINK; + + tag_type = __near_tag_get_type(adapter->tag_link); + target_idx = near_tag_get_target_idx(adapter->tag_link); + + DBG("tag type %d", tag_type); + + __near_adapter_remove_target(adapter->idx, target_idx); + + if (adapter->tag_sock == -1) + return -ENOLINK; + + if (adapter->watch > 0) { + g_source_remove(adapter->watch); + adapter->watch = 0; + } + + g_io_channel_unref(adapter->channel); + adapter->channel = NULL; + adapter->tag_sock = -1; + adapter->tag_link = NULL; + + return 0; +} + +int near_adapter_send(uint32_t idx, uint8_t *buf, size_t length, + near_recv cb, void *data, near_release data_rel) +{ + struct near_adapter *adapter; + struct near_adapter_ioreq *req = NULL; + int err; + + DBG("idx %d", idx); + + adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx)); + if (!adapter) { + err = -ENODEV; + goto out_err; + } + + if (adapter->tag_sock == -1 || !adapter->tag_link) { + err = -ENOLINK; + goto out_err; + } + + if (cb && adapter->watch != 0) { + req = g_try_malloc0(sizeof(*req)); + if (!req) { + err = -ENOMEM; + goto out_err; + } + + DBG("req %p cb %p data %p", req, cb, data); + + req->target_idx = near_tag_get_target_idx(adapter->tag_link); + req->cb = cb; + req->data = data; + + adapter->ioreq_list = + g_list_append(adapter->ioreq_list, req); + } + + err = send(adapter->tag_sock, buf, length, 0); + if (err < 0) + goto out_err; + + return err; + +out_err: + if (req) { + GList *last = g_list_last(adapter->ioreq_list); + + g_free(req); + adapter->ioreq_list = + g_list_delete_link(adapter->ioreq_list, last); + } + + if (data_rel) + return (*data_rel)(err, data); + + return err; +} + +static void adapter_listen(gpointer key, gpointer value, gpointer user_data) +{ + struct near_adapter *adapter = value; + struct near_device_driver *driver = user_data; + + DBG("%s", adapter->path); + + if (!adapter->path) + return; + + driver->listen(adapter->idx, device_read_cb); +} + +void __near_adapter_listen(struct near_device_driver *driver) +{ + g_hash_table_foreach(adapter_hash, adapter_listen, driver); +} + +int __near_adapter_init(void) +{ + DBG(""); + + connection = near_dbus_get_connection(); + + adapter_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, free_adapter); + + return 0; +} + +void __near_adapter_cleanup(void) +{ + DBG(""); + + g_hash_table_destroy(adapter_hash); + adapter_hash = NULL; +}
diff --git a/neard/src/agent.c b/neard/src/agent.c new file mode 100644 index 0000000..6e193f9 --- /dev/null +++ b/neard/src/agent.c
@@ -0,0 +1,844 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "near.h" + +#ifndef DBUS_TIMEOUT_USE_DEFAULT +#define DBUS_TIMEOUT_USE_DEFAULT (-1) +#endif + +static DBusConnection *connection = NULL; +static GHashTable *ndef_app_hash; +static GHashTable *ho_agent_hash; + +struct near_ndef_agent { + char *sender; + char *path; + char *record_type; + guint watch; +}; + +struct near_handover_agent { + enum ho_agent_carrier carrier; + guint watch; + char *sender; + char *path; +}; + +static void ndef_agent_free(gpointer data) +{ + struct near_ndef_agent *agent = data; + + DBG(""); + + if (!agent || agent->watch == 0) + return; + + g_dbus_remove_watch(connection, agent->watch); + + g_free(agent->sender); + g_free(agent->path); + g_free(agent); +} + +static void ndef_agent_release(gpointer key, gpointer data, gpointer user_data) +{ + struct near_ndef_agent *agent = data; + DBusMessage *message; + + if (!agent) + return; + + DBG("%s %s", agent->sender, agent->path); + + message = dbus_message_new_method_call(agent->sender, agent->path, + NFC_NDEF_AGENT_INTERFACE, "Release"); + if (!message) + return; + + dbus_message_set_no_reply(message, TRUE); + + g_dbus_send_message(connection, message); +} + +static void ndef_agent_disconnect(DBusConnection *conn, void *user_data) +{ + struct near_ndef_agent *agent = user_data; + + DBG("agent %s disconnected", agent->path); + + g_hash_table_remove(ndef_app_hash, agent->record_type); +} + +static void append_ndef(DBusMessageIter *iter, void *user_data) +{ + GList *records = user_data; + + __near_ndef_append_records(iter, records); +} + +static void ndef_agent_push_records(struct near_ndef_agent *agent, + struct near_ndef_record *record, + GList *records) +{ + DBusMessageIter iter, dict; + DBusMessage *message; + char *path; + uint8_t *payload; + size_t payload_len; + + DBG(""); + + if (!agent->sender || !agent->path) + return; + + DBG("Sending NDEF to %s %s", agent->path, agent->sender); + + message = dbus_message_new_method_call(agent->sender, agent->path, + NFC_NDEF_AGENT_INTERFACE, + "GetNDEF"); + if (!message) + return; + + path = __near_ndef_record_get_path(record); + payload = __near_ndef_record_get_payload(record, &payload_len); + + dbus_message_iter_init_append(message, &iter); + + near_dbus_dict_open(&iter, &dict); + near_dbus_dict_append_basic(&dict, "Record", + DBUS_TYPE_STRING, &path); + near_dbus_dict_append_fixed_array(&dict, "Payload", + DBUS_TYPE_BYTE, &payload, payload_len); + near_dbus_dict_append_array(&dict, "NDEF", + DBUS_TYPE_BYTE, append_ndef, records); + near_dbus_dict_close(&iter, &dict); + + DBG("sending..."); + + dbus_message_set_no_reply(message, TRUE); + + g_dbus_send_message(connection, message); +} + +void __near_agent_ndef_parse_records(GList *records) +{ + GList *list; + struct near_ndef_record *record; + struct near_ndef_agent *agent; + char *type; + + DBG(""); + + for (list = records, agent = NULL; list; list = list->next) { + record = list->data; + type = __near_ndef_record_get_type(record); + + if (!type) + continue; + + DBG("Looking for type %s", type); + + agent = g_hash_table_lookup(ndef_app_hash, type); + if (agent) + ndef_agent_push_records(agent, record, records); + } +} + +static int ndef_register(const char *sender, const char *path, + const char *record_type) +{ + struct near_ndef_agent *agent; + + DBG("%s registers path %s for %s", sender, path, record_type); + + if (g_hash_table_lookup(ndef_app_hash, record_type)) + return -EEXIST; + + agent = g_try_malloc0(sizeof(struct near_ndef_agent)); + if (!agent) + return -ENOMEM; + + agent->sender = g_strdup(sender); + agent->path = g_strdup(path); + agent->record_type = g_strdup(record_type); + + if (!agent->sender || !agent->path || + !agent->record_type) { + g_free(agent); + return -ENOMEM; + } + + agent->watch = g_dbus_add_disconnect_watch(connection, sender, + ndef_agent_disconnect, + agent, NULL); + g_hash_table_insert(ndef_app_hash, agent->record_type, agent); + + return 0; +} + +static int ndef_unregister(const char *sender, const char *path, + const char *record_type) +{ + struct near_ndef_agent *agent; + + DBG("sender %s path %s type %s", sender, path, record_type); + + agent = g_hash_table_lookup(ndef_app_hash, record_type); + if (!agent) + return -EINVAL; + + if (strcmp(agent->path, path) != 0 || strcmp(agent->sender, sender) != 0) + return -EINVAL; + + g_hash_table_remove(ndef_app_hash, record_type); + + return 0; +} + +static enum carrier_power_state string2cps(const char *state) +{ + if (strcasecmp(state, "active") == 0) + return CPS_ACTIVE; + + if (strcasecmp(state, "inactive") == 0) + return CPS_INACTIVE; + + if (strcasecmp(state, "activating") == 0) + return CPS_ACTIVATING; + + return CPS_UNKNOWN; +} + +static enum ho_agent_carrier string2carrier(const char *carrier) +{ + if (strcasecmp(carrier, NEAR_HANDOVER_AGENT_BLUETOOTH) == 0) + return HO_AGENT_BT; + + if (strcasecmp(carrier, NEAR_HANDOVER_AGENT_WIFI) == 0) + return HO_AGENT_WIFI; + + return HO_AGENT_UNKNOWN; +} + +static struct carrier_data *parse_reply(DBusMessage *reply) +{ + DBusMessageIter args; + DBusMessageIter data; + struct carrier_data *c_data; + + c_data = g_try_new0(struct carrier_data, 1); + if (!c_data) + return NULL; + + c_data->state = CPS_UNKNOWN; + + dbus_message_iter_init(reply, &args); + dbus_message_iter_recurse(&args, &data); + + while (dbus_message_iter_get_arg_type(&data) == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter value; + DBusMessageIter entry; + DBusMessageIter array; + const char *key; + int var; + + dbus_message_iter_recurse(&data, &entry); + dbus_message_iter_get_basic(&entry, &key); + + dbus_message_iter_next(&entry); + dbus_message_iter_recurse(&entry, &value); + + var = dbus_message_iter_get_arg_type(&value); + + if (strcasecmp(key, "State") == 0) { + const char *state; + + if (var != DBUS_TYPE_STRING) + goto failed; + + dbus_message_iter_get_basic(&value, &state); + + c_data->state = string2cps(state); + if (c_data->state == CPS_UNKNOWN) + goto failed; + } else if (strcasecmp(key, "EIR") == 0) { + int size; + void *oob_data; + + if (var != DBUS_TYPE_ARRAY) + goto failed; + + dbus_message_iter_recurse(&value, &array); + dbus_message_iter_get_fixed_array(&array, &oob_data, + &size); + + if (size > UINT8_MAX || size < 8) + goto failed; + + memcpy(c_data->data, oob_data, size); + c_data->size = size; + c_data->type = BT_MIME_V2_1; + } else if (strcasecmp(key, "nokia.com:bt") == 0) { + int size; + void *oob_data; + + /* prefer EIR over nokia.com:bt */ + if (c_data->type == BT_MIME_V2_1) + continue; + + dbus_message_iter_recurse(&value, &array); + dbus_message_iter_get_fixed_array(&array, &oob_data, + &size); + + if (size > UINT8_MAX || size < 8) + goto failed; + + memcpy(c_data->data, oob_data, size); + c_data->size = size; + c_data->type = BT_MIME_V2_1; + } else if (strcasecmp(key, "WSC") == 0) { + int size; + void *oob_data; + + if (var != DBUS_TYPE_ARRAY) + goto failed; + + dbus_message_iter_recurse(&value, &array); + dbus_message_iter_get_fixed_array(&array, &oob_data, + &size); + memcpy(c_data->data, oob_data, size); + c_data->size = size; + c_data->type = WIFI_WSC_MIME; + } + + dbus_message_iter_next(&data); + } + + /* State can be present only if EIR or nokia.com:bt is also present */ + if (c_data->state != CPS_UNKNOWN && c_data->size == 0) + goto failed; + + return c_data; + +failed: + g_free(c_data); + return NULL; +} + +static const char *cps2string[] = { + "inactive", + "active", + "activating", +}; + +static void prepare_data(DBusMessage *message, struct carrier_data *data) +{ + DBusMessageIter iter; + DBusMessageIter dict; + char *name = NULL; + + DBG("data %p", data); + + dbus_message_iter_init_append(message, &iter); + + near_dbus_dict_open(&iter, &dict); + + if (data) { + void *pdata = data->data; + + switch (data->type) { + case BT_MIME_V2_1: + name = "EIR"; + break; + + case BT_MIME_V2_0: + name = "nokia.com:bt"; + break; + + case WIFI_WSC_MIME: + name = "WSC"; + break; + } + + near_dbus_dict_append_fixed_array(&dict, name, DBUS_TYPE_BYTE, + &pdata, data->size); + + if (data->state != CPS_UNKNOWN) { + const char *state = cps2string[data->state]; + + near_dbus_dict_append_basic(&dict, "State", + DBUS_TYPE_STRING, &state); + } + } + + near_dbus_dict_close(&iter, &dict); +} + +struct carrier_data *__near_agent_handover_request_data( + enum ho_agent_carrier carrier, + struct carrier_data *data) +{ + DBusMessage *message; + DBusMessage *reply; + DBusError error; + struct carrier_data *data_reply; + struct near_handover_agent *agent = NULL; + + agent = g_hash_table_lookup(ho_agent_hash, + GINT_TO_POINTER(carrier)); + if (!agent) + return NULL; + + message = dbus_message_new_method_call(agent->sender, + agent->path, NFC_HANDOVER_AGENT_INTERFACE, + "RequestOOB"); + if (!message) + return NULL; + + prepare_data(message, data); + + dbus_error_init(&error); + + reply = dbus_connection_send_with_reply_and_block(connection, message, + DBUS_TIMEOUT_USE_DEFAULT, &error); + + dbus_message_unref(message); + + if (!reply) { + if (dbus_error_is_set(&error)) { + near_error("RequestOOB failed: %s", error.message); + dbus_error_free(&error); + } else { + near_error("RequestOOB failed"); + } + return NULL; + } + + data_reply = parse_reply(reply); + + dbus_message_unref(reply); + + DBG("OOB data %p", data_reply); + + return data_reply; +} + +int __near_agent_handover_push_data(enum ho_agent_carrier carrier, + struct carrier_data *data) +{ + DBusMessage *message; + DBusMessage *reply; + DBusError error; + struct near_handover_agent *agent = NULL; + + agent = g_hash_table_lookup(ho_agent_hash, GINT_TO_POINTER(carrier)); + if (!agent) + return -ESRCH; + + message = dbus_message_new_method_call(agent->sender, + agent->path, NFC_HANDOVER_AGENT_INTERFACE, + "PushOOB"); + if (!message) + return -ENOMEM; + + prepare_data(message, data); + + dbus_error_init(&error); + + reply = dbus_connection_send_with_reply_and_block(connection, message, + DBUS_TIMEOUT_USE_DEFAULT, &error); + + dbus_message_unref(message); + + if (reply) { + dbus_message_unref(reply); + return 0; + } + + if (dbus_error_is_set(&error)) { + near_error("PushOOB failed: %s", error.message); + dbus_error_free(&error); + } else { + near_error("PushOOB failed"); + } + + return -EIO; +} + +static void handover_agent_free(gpointer data) +{ + struct near_handover_agent *agent = data; + + if (!agent) + return; + + g_free(agent->sender); + agent->sender = NULL; + + g_free(agent->path); + agent->path = NULL; + + if (agent->watch == 0) + return; + + g_dbus_remove_watch(connection, agent->watch); + agent->watch = 0; + + g_free(agent); +} + +static void handover_agent_disconnect(DBusConnection *conn, void *data) +{ + struct near_handover_agent *agent = data; + + DBG("data %p", data); + + if (!agent) + return; + + switch (agent->carrier) { + case HO_AGENT_BT: + /* start watching for legacy bluez */ + __near_bluetooth_legacy_start(); + break; + + case HO_AGENT_WIFI: + case HO_AGENT_UNKNOWN: + break; + } + + handover_agent_free(agent); +} + +static void handover_agent_release(gpointer key, gpointer data, + gpointer user_data) +{ + struct near_handover_agent *agent = data; + DBusMessage *message; + + if (!agent || agent->watch == 0) + return; + + message = dbus_message_new_method_call(agent->sender, agent->path, + "org.neard.HandoverAgent", + "Release"); + if (message) + g_dbus_send_message(connection, message); +} + +static int create_handover_agent(const char *sender, const char *path, + enum ho_agent_carrier carrier) +{ + struct near_handover_agent *agent; + + agent = g_try_malloc0(sizeof(struct near_handover_agent)); + if (!agent) + return -ENOMEM; + + agent->sender = g_strdup(sender); + agent->path = g_strdup(path); + agent->carrier = carrier; + agent->watch = g_dbus_add_disconnect_watch(connection, sender, + handover_agent_disconnect, agent, NULL); + + g_hash_table_insert(ho_agent_hash, GINT_TO_POINTER(carrier), agent); + + DBG("handover agent registered"); + + switch (agent->carrier) { + case HO_AGENT_BT: + /* stop watching for legacy bluez */ + __near_bluetooth_legacy_stop(); + break; + + case HO_AGENT_WIFI: + case HO_AGENT_UNKNOWN: + break; + } + + return 0; +} + +static int handover_register(const char *sender, const char *path, + const char *carrier) +{ + struct near_handover_agent *agent; + enum ho_agent_carrier ho_carrier; + + DBG("sender %s path %s carrier %s", sender, path, carrier); + + ho_carrier = string2carrier(carrier); + + if (ho_carrier == HO_AGENT_UNKNOWN) + return -EINVAL; + + agent = g_hash_table_lookup(ho_agent_hash, GINT_TO_POINTER(ho_carrier)); + if (agent) + return -EEXIST; + + return create_handover_agent(sender, path, ho_carrier); +} + +static int handover_unregister(const char *sender, const char *path, + const char *carrier) +{ + struct near_handover_agent *agent; + enum ho_agent_carrier ho_carrier; + + DBG("sender %s path %s carrier %s", sender, path, carrier); + + ho_carrier = string2carrier(carrier); + agent = g_hash_table_lookup(ho_agent_hash, GINT_TO_POINTER(ho_carrier)); + if (!agent) + return -ESRCH; + + if (strcmp(agent->path, path) != 0 || + strcmp(agent->sender, sender) != 0) + return -ESRCH; + + g_hash_table_remove(ho_agent_hash, GINT_TO_POINTER(ho_carrier)); + + return 0; +} + +bool __near_agent_handover_registered(enum ho_agent_carrier carrier) +{ + struct near_handove_agent *agent = NULL; + + agent = g_hash_table_lookup(ho_agent_hash, GINT_TO_POINTER(carrier)); + + return agent ? TRUE : FALSE; +} + +static DBusMessage *register_handover_agent(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessageIter iter; + const char *sender, *path, *carrier; + int err; + + DBG("conn %p", conn); + + sender = dbus_message_get_sender(msg); + + if (!dbus_message_iter_init(msg, &iter)) + return __near_error_invalid_arguments(msg); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &path); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &carrier); + + err = handover_register(sender, path, carrier); + if (err < 0) + return __near_error_failed(msg, -err); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static DBusMessage *unregister_handover_agent(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessageIter iter; + const char *sender, *path, *carrier; + int err; + + DBG("conn %p", conn); + + sender = dbus_message_get_sender(msg); + + if (!dbus_message_iter_init(msg, &iter)) + return __near_error_invalid_arguments(msg); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &path); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &carrier); + + err = handover_unregister(sender, path, carrier); + if (err < 0) + return __near_error_failed(msg, -err); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static DBusMessage *register_ndef_agent(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessageIter iter; + const char *sender, *path, *type; + int err; + + DBG("conn %p", conn); + + sender = dbus_message_get_sender(msg); + + if (!dbus_message_iter_init(msg, &iter)) + return __near_error_invalid_arguments(msg); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &path); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &type); + + err = ndef_register(sender, path, type); + if (err < 0) + return __near_error_failed(msg, -err); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static DBusMessage *unregister_ndef_agent(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessageIter iter; + const char *sender, *path, *type; + int err; + + DBG("conn %p", conn); + + sender = dbus_message_get_sender(msg); + + if (!dbus_message_iter_init(msg, &iter)) + return __near_error_invalid_arguments(msg); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &path); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + return __near_error_invalid_arguments(msg); + + dbus_message_iter_get_basic(&iter, &type); + + err = ndef_unregister(sender, path, type); + if (err < 0) + return __near_error_failed(msg, -err); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static const GDBusMethodTable manager_methods[] = { + { GDBUS_METHOD("RegisterHandoverAgent", + GDBUS_ARGS({ "path", "o" }, { "type", "s"}), + NULL, register_handover_agent) }, + { GDBUS_METHOD("UnregisterHandoverAgent", + GDBUS_ARGS({ "path", "o" }, { "type", "s"}), + NULL, unregister_handover_agent) }, + { GDBUS_METHOD("RegisterNDEFAgent", + GDBUS_ARGS({"path", "o"}, {"type", "s"}), + NULL, register_ndef_agent) }, + { GDBUS_METHOD("UnregisterNDEFAgent", + GDBUS_ARGS({"path", "o"}, {"type", "s"}), + NULL, unregister_ndef_agent) }, + { }, +}; + +int __near_agent_init(void) +{ + DBG(""); + + connection = near_dbus_get_connection(); + if (!connection) + return -1; + + g_dbus_register_interface(connection, NFC_PATH, + NFC_AGENT_MANAGER_INTERFACE, + manager_methods, + NULL, NULL, NULL, NULL); + + /* + * Legacy interface, for backward compatibility only. + * To be removed after 0.16. + */ + g_dbus_register_interface(connection, "/", "org.neard.Manager", + manager_methods, + NULL, NULL, NULL, NULL); + + + ndef_app_hash = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, ndef_agent_free); + + ho_agent_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, handover_agent_free); + + return 0; +} + +void __near_agent_cleanup(void) +{ + DBG(""); + + g_hash_table_foreach(ndef_app_hash, ndef_agent_release, NULL); + g_hash_table_destroy(ndef_app_hash); + ndef_app_hash = NULL; + + g_hash_table_foreach(ho_agent_hash, handover_agent_release, NULL); + g_hash_table_destroy(ho_agent_hash); + ho_agent_hash = NULL; + + /* + * Legacy interface, for backward compatibility only. + * To be removed after 0.16. + */ + g_dbus_unregister_interface(connection, "/", "org.neard.Manager"); + + g_dbus_unregister_interface(connection, NFC_PATH, + NFC_AGENT_MANAGER_INTERFACE); + + + dbus_connection_unref(connection); +}
diff --git a/neard/src/bluetooth.c b/neard/src/bluetooth.c new file mode 100644 index 0000000..3e67f1c --- /dev/null +++ b/neard/src/bluetooth.c
@@ -0,0 +1,1167 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <gdbus.h> + +#include "near.h" + +#define BLUEZ_SERVICE "org.bluez" +#define MANAGER_INTF BLUEZ_SERVICE ".Manager" +#define ADAPTER_INTF BLUEZ_SERVICE ".Adapter" +#define OOB_INTF BLUEZ_SERVICE ".OutOfBand" +#define DEFAULT_ADAPTER "DefaultAdapter" +#define ADAPTER_REMOVED "AdapterRemoved" +#define DEFAULT_ADAPTER_CHANGED "DefaultAdapterChanged" +#define ADAPTER_PROPERTY_CHANGED "PropertyChanged" +#define MANAGER_PATH "/" +#define OOB_AGENT "/org/neard/agent/neard_oob" + +#define BT_NOINPUTOUTPUT "NoInputNoOutput" +#define BT_DISPLAY_YESNO "DisplayYesNo" + +#define DBUS_MANAGER_INTF "org.freedesktop.DBus.ObjectManager" +#define AGENT_REGISTER_TIMEOUT 2 + +/* BT EIR list */ +#define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */ +#define EIR_NAME_SHORT 0x08 /* shortened local name */ +#define EIR_NAME_COMPLETE 0x09 /* complete local name */ + +/* Specific OOB EIRs */ +#define EIR_CLASS_OF_DEVICE 0x0D /* class of device */ +#define EIR_SP_HASH 0x0E /* simple pairing hash C */ +#define EIR_SP_RANDOMIZER 0x0F /* simple pairing randomizer R */ +/* Optional EIRs */ +#define EIR_DEVICE_ID 0x10 /* device ID */ +#define EIR_SECURITY_MGR_FLAGS 0x11 /* security manager flags */ + +#define EIR_SIZE_LEN 1 +#define EIR_HEADER_LEN (EIR_SIZE_LEN + 1) +#define BT_ADDRESS_SIZE 6 +#define COD_SIZE 3 +#define OOB_SP_SIZE 16 +#define EIR_SIZE_MAX 255 + +struct near_oob_data { + char *def_adapter; + + char *bd_addr; /* oob mandatory */ + + /* optional */ + char *bt_name; /* short or long name */ + uint8_t bt_name_len; + int class_of_device; /* Class of device */ + bool powered; + bool pairable; + bool discoverable; + uint8_t *uuids; + int uuids_len; + + uint8_t *spair_hash; /* OOB hash Key */ + uint8_t *spair_randomizer; /* OOB randomizer key */ + uint8_t authentication[OOB_SP_SIZE]; /* On BT 2.0 */ + uint8_t security_manager_oob_flags; /* see BT Core 4.0 */ +}; + +static DBusConnection *bt_conn; +static struct near_oob_data bt_def_oob_data; + +static guint watch; +static guint removed_watch; +static guint adapter_watch; +static guint adapter_props_watch; + +static guint register_bluez_timer; + +static void __bt_eir_free(struct near_oob_data *oob) +{ + DBG(""); + + if (oob->def_adapter) { + g_free(oob->def_adapter); + oob->def_adapter = NULL; + } + + if (oob->bd_addr) { + g_free(oob->bd_addr); + oob->bd_addr = NULL; + } + + if (oob->bt_name) { + g_free(oob->bt_name); + oob->bt_name = NULL; + } + + if (oob->spair_hash) { + g_free(oob->spair_hash); + oob->spair_hash = NULL; + } + + if (oob->spair_randomizer) { + g_free(oob->spair_randomizer); + oob->spair_randomizer = NULL; + } +} + +static void bt_eir_free(struct near_oob_data *oob) +{ + __bt_eir_free(oob); + + g_free(oob); +} + +/* D-Bus helper functions */ +static int bt_generic_call(DBusConnection *conn, + struct near_oob_data *oob, /* user data */ + const char *dest, /* method call */ + const char *path, + const char *interface, + const char *method, + DBusPendingCallNotifyFunction bt_cb, /* callback */ + int type, ...) /* params */ +{ + DBusMessage *msg; + DBusPendingCall *pending; + va_list args; + int err; + + DBG("%s", method); + + msg = dbus_message_new_method_call(dest, path, interface, method); + + if (!msg) { + near_error("Unable to allocate new D-Bus %s message", method); + return -ENOMEM; + } + + va_start(args, type); + + if (!dbus_message_append_args_valist(msg, type, args)) { + va_end(args); + err = -EIO; + goto error_done; + } + va_end(args); + + if (!dbus_connection_send_with_reply(conn, msg, &pending, -1)) { + near_error("Sending %s failed", method); + err = -EIO; + goto error_done; + } + + if (!pending) { + near_error("D-Bus connection not available"); + err = -EIO; + goto error_done; + } + + /* Prepare for notification */ + dbus_pending_call_set_notify(pending, bt_cb, oob, NULL); + err = 0 ; + +error_done: + dbus_message_unref(msg); + return err; +} + +static void bt_create_paired_device_cb(DBusPendingCall *pending, + void *user_data) +{ + DBusMessage *reply; + DBusError error; + struct near_oob_data *oob = user_data; + + DBG(""); + + reply = dbus_pending_call_steal_reply(pending); + if (!reply) + return; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply)) { + near_error("%s", error.message); + dbus_error_free(&error); + goto cb_done; + } + + DBG("Successful pairing"); + +cb_done: + /* task completed - clean memory*/ + bt_eir_free(oob); + + dbus_message_unref(reply); + dbus_pending_call_unref(pending); +} + +static int bt_create_paired_device(DBusConnection *conn, + struct near_oob_data *oob, + const char *capabilities) +{ + const char *agent_path = OOB_AGENT; + + return bt_generic_call(bt_conn, oob, BLUEZ_SERVICE, + oob->def_adapter, ADAPTER_INTF, "CreatePairedDevice", + bt_create_paired_device_cb, + /* params */ + DBUS_TYPE_STRING, &oob->bd_addr, + DBUS_TYPE_OBJECT_PATH, &agent_path, + DBUS_TYPE_STRING, &capabilities, + DBUS_TYPE_INVALID); +} + +static void bt_oob_add_remote_data_cb(DBusPendingCall *pending, void *user_data) +{ + DBusMessage *reply; + DBusError error; + struct near_oob_data *oob = user_data; + + DBG(""); + + reply = dbus_pending_call_steal_reply(pending); + if (!reply) + return; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply)) + goto cb_fail; + + near_info("OOB data added"); + + dbus_message_unref(reply); + dbus_pending_call_unref(pending); + + /* Jump to the next: Pairing !!!*/ + DBG("Try to pair devices..."); + bt_create_paired_device(bt_conn, oob, BT_DISPLAY_YESNO); + return; + +cb_fail: + near_error("%s", error.message); + dbus_error_free(&error); + + bt_eir_free(oob); + + dbus_message_unref(reply); + dbus_pending_call_unref(pending); +} + +static int bt_oob_add_remote_data(DBusConnection *conn, + struct near_oob_data *oob) +{ + int16_t hash_len = 16; + int16_t rdm_len = 16; + + return bt_generic_call(bt_conn, oob, BLUEZ_SERVICE, + oob->def_adapter, OOB_INTF, "AddRemoteData", + bt_oob_add_remote_data_cb, + /* params */ + DBUS_TYPE_STRING, &oob->bd_addr, + DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE, &oob->spair_hash, hash_len, + DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE, &oob->spair_randomizer, rdm_len, + DBUS_TYPE_INVALID); +} + +/* Pairing: JustWorks or OOB */ +static int bt_do_pairing(struct near_oob_data *oob) +{ + int err = 0; + + DBG("%s", oob->bd_addr); + + /* Is this a *real* oob pairing or a "JustWork" */ + if ((oob->spair_hash) && (oob->spair_randomizer)) + err = bt_oob_add_remote_data(bt_conn, oob); + else + err = bt_create_paired_device(bt_conn, oob, + BT_NOINPUTOUTPUT); + + if (err < 0) + near_error("Pairing failed. Err[%d]", err); + + return err; +} + +/* + */ +static int extract_properties(DBusMessage *reply, struct near_oob_data *oob) +{ + char *data = NULL; + int idata; + int i, j; + + DBusMessageIter array, dict; + + if (!dbus_message_iter_init(reply, &array)) + return -1; + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY) + return -1; + + dbus_message_iter_recurse(&array, &dict); + + while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter entry, value; + const char *key; + + dbus_message_iter_recurse(&dict, &entry); + dbus_message_iter_get_basic(&entry, &key); + + dbus_message_iter_next(&entry); + dbus_message_iter_recurse(&entry, &value); + + if (g_str_equal(key, "Address")) { + dbus_message_iter_get_basic(&value, &data); + + /* Now, fill the local struct */ + oob->bd_addr = g_try_malloc0(BT_ADDRESS_SIZE); + if (!oob->bd_addr) + return -ENOMEM; + + /* Address is like: "ff:ee:dd:cc:bb:aa" */ + for (i = 5, j = 0 ; i >= 0; i--, j += 3) + oob->bd_addr[i] = strtol(data + j, NULL, 16); + DBG("local address: %s", data); + + } else if (g_str_equal(key, "Name")) { + dbus_message_iter_get_basic(&value, &data); + oob->bt_name = g_strdup(data); + if (oob->bt_name) { + oob->bt_name_len = strlen(oob->bt_name); + DBG("local name: %s", oob->bt_name); + } + + } else if (g_str_equal(key, "Class")) { + dbus_message_iter_get_basic(&value, &idata); + oob->class_of_device = idata; + + } else if (g_str_equal(key, "Powered")) { + dbus_message_iter_get_basic(&value, &idata); + oob->powered = idata; + + } else if (g_str_equal(key, "Discoverable")) { + dbus_message_iter_get_basic(&value, &idata); + oob->discoverable = idata; + + } else if (g_str_equal(key, "Pairable")) { + dbus_message_iter_get_basic(&value, &idata); + oob->pairable = idata; + + } else if (g_str_equal(key, "UUIDs")) { + oob->uuids_len = sizeof(value); + oob->uuids = g_try_malloc0(oob->uuids_len); + if (!oob->uuids) + return -ENOMEM; + memcpy(oob->uuids, &value, oob->uuids_len); + } + + dbus_message_iter_next(&dict); + } + + return 0; +} + +static int bt_parse_properties(DBusMessage *reply, void *user_data) +{ + struct near_oob_data *bt_props = user_data; + + DBG(""); + + /* Free datas */ + g_free(bt_props->bd_addr); + g_free(bt_props->bt_name); + + /* Grab properties from dbus */ + if (extract_properties(reply, bt_props) < 0) + goto fail; + + return 0; + +fail: + g_free(bt_props->bd_addr); + bt_props->bd_addr = NULL; + + g_free(bt_props->bt_name); + bt_props->bt_name = NULL; + + return -ENOMEM; +} + +static gboolean bt_adapter_property_changed(DBusConnection *conn, + DBusMessage *message, + void *user_data) +{ + DBusMessageIter iter; + DBusMessageIter var; + const char *property; + + if (!dbus_message_iter_init(message, &iter)) + return TRUE; + + dbus_message_iter_get_basic(&iter, &property); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) + return TRUE; + + dbus_message_iter_recurse(&iter, &var); + + if (g_str_equal(property, "Name")) { + const char *name; + + if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING) + return TRUE; + + dbus_message_iter_get_basic(&var, &name); + + g_free(bt_def_oob_data.bt_name); + bt_def_oob_data.bt_name = g_strdup(name); + + if (bt_def_oob_data.bt_name) + bt_def_oob_data.bt_name_len = strlen(name); + else + bt_def_oob_data.bt_name_len = 0; + + DBG("%s: %s", property, name); + } else if (g_str_equal(property, "Class")) { + int class; + + if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_UINT32) + return TRUE; + + dbus_message_iter_get_basic(&var, &class); + bt_def_oob_data.class_of_device = class; + + DBG("%s: %x", property, bt_def_oob_data.class_of_device); + } else if (g_str_equal(property, "Powered")) { + dbus_bool_t powered; + + if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN) + return TRUE; + + dbus_message_iter_get_basic(&var, &powered); + bt_def_oob_data.powered = powered; + + DBG("%s: %u", property, bt_def_oob_data.powered); + } + + return TRUE; +} + +/* Get default local adapter properties */ +static void bt_get_properties_cb(DBusPendingCall *pending, void *user_data) +{ + struct near_oob_data *bt_props = user_data; + DBusMessage *reply; + DBusError error; + int err; + + DBG(""); + + reply = dbus_pending_call_steal_reply(pending); + if (!reply) + return; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply)) + goto cb_fail; + + err = bt_parse_properties(reply, bt_props); + if (err < 0) + near_error("Problem parsing local properties %d", err); + else + DBG("Get Properties complete: %s", bt_props->def_adapter); + + adapter_props_watch = g_dbus_add_signal_watch(bt_conn, NULL, NULL, + ADAPTER_INTF, + ADAPTER_PROPERTY_CHANGED, + bt_adapter_property_changed, + NULL, NULL); + + /* clean */ + dbus_message_unref(reply); + dbus_pending_call_unref(pending); + return; + +cb_fail: + near_error("%s", error.message); + dbus_error_free(&error); + + dbus_message_unref(reply); + dbus_pending_call_unref(pending); +} + +static void bt_get_default_adapter_cb(DBusPendingCall *pending, void *user_data) +{ + struct near_oob_data *bt_props = user_data; + DBusMessage *reply; + DBusError error; + gchar *path; + + DBG(""); + + reply = dbus_pending_call_steal_reply(pending); + if (!reply) + return; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, reply)) + goto cb_fail; + + if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, + &path, DBUS_TYPE_INVALID)) + goto cb_fail; + + /* Save the default adapter */ + bt_props->def_adapter = g_strdup(path); + DBG("Using default adapter %s", bt_props->def_adapter); + + /* clean */ + dbus_message_unref(reply); + dbus_pending_call_unref(pending); + + /* Jump on getAdapterProperties */ + bt_generic_call(bt_conn, bt_props, + BLUEZ_SERVICE, + bt_props->def_adapter, + ADAPTER_INTF, "GetProperties", + bt_get_properties_cb, + DBUS_TYPE_INVALID); + return; + +cb_fail: + near_error("Could not get Bluetooth default adapter %s", error.message); + dbus_error_free(&error); + + dbus_message_unref(reply); + dbus_pending_call_unref(pending); +} + +static int bt_refresh_adapter_props(DBusConnection *conn, void *user_data) +{ + DBG("%p %p", conn, user_data); + + return bt_generic_call(conn, user_data, + BLUEZ_SERVICE, + MANAGER_PATH, MANAGER_INTF, + DEFAULT_ADAPTER, + bt_get_default_adapter_cb, + DBUS_TYPE_INVALID); +} + +/* Parse and fill the bluetooth oob information block */ +static void bt_parse_eir(uint8_t *eir_data, uint16_t eir_data_len, + struct near_oob_data *oob, uint16_t *props) +{ + char *tmp; + uint16_t len = 0; + + DBG("total len: %u", eir_data_len); + + while (len < eir_data_len - 1) { + uint8_t eir_len = eir_data[0]; /* EIR field length */ + uint8_t eir_code; /* EIR field type*/ + uint8_t data_len; /* EIR data length */ + uint8_t *data; + + /* check for early termination */ + if (eir_len == 0) + break; + + len += eir_len + 1; + + /* Do not continue EIR Data parsing if got incorrect length */ + if (len > eir_data_len) + break; + + data_len = eir_len - 1; + + eir_code = eir_data[1]; /* EIR code */ + data = &eir_data[2]; + + DBG("type 0x%.2X data_len %u", eir_code, data_len); + + switch (eir_code) { + case EIR_NAME_SHORT: + case EIR_NAME_COMPLETE: + oob->bt_name = g_try_malloc0(data_len + 1); /* eos */ + if (oob->bt_name) { + oob->bt_name_len = data_len; + memcpy(oob->bt_name, data, oob->bt_name_len); + oob->bt_name[data_len] = 0; /* end str*/ + } + break; + + case EIR_CLASS_OF_DEVICE: + tmp = g_strdup_printf("%02X%02X%02X", + *data, *(data + 1), *(data + 2)); + if (tmp) { + oob->class_of_device = strtol(tmp, NULL, 16); + *props |= OOB_PROPS_COD; + } + g_free(tmp); + break; + + case EIR_SP_HASH: + oob->spair_hash = g_try_malloc0(OOB_SP_SIZE); + if (oob->spair_hash) { + memcpy(oob->spair_hash, data, OOB_SP_SIZE); + *props |= OOB_PROPS_SP_HASH; + } + break; + + case EIR_SP_RANDOMIZER: + oob->spair_randomizer = g_try_malloc0(OOB_SP_SIZE); + if (oob->spair_randomizer) { + memcpy(oob->spair_randomizer, + data, OOB_SP_SIZE); + *props |= OOB_PROPS_SP_RANDOM; + } + break; + + case EIR_SECURITY_MGR_FLAGS: + oob->security_manager_oob_flags = *data; + break; + + case EIR_UUID128_ALL: + /* TODO: Process uuids128 + * */ + break; + + default: /* ignore and skip */ + near_error("Unknown EIR x%02x (len: %d)", eir_code, + eir_len); + break; + } + /* Next eir */ + eir_data += eir_len + 1; + } +} + +/* + * Because of some "old" implementation, "version" will help + * to determine the record data structure. + * Some specifications are proprietary (eg. "short mode") + * and are not fully documented. + * mime_properties is a bitmask and should reflect the fields found in + * the incoming oob. + */ +int __near_bluetooth_parse_oob_record(struct carrier_data *data, + uint16_t *mime_properties, + bool pair) +{ + struct near_oob_data *oob; + uint16_t bt_oob_data_size; + uint8_t *ptr = data->data; + uint8_t marker; + char *tmp; + + DBG(""); + + oob = g_try_malloc0(sizeof(struct near_oob_data)); + + if (data->type == BT_MIME_V2_1) { + /* + * Total OOB data size (including size bytes) + * Some implementations (e.g. Android 4.1) stores + * the data_size in big endian but NDEF forum spec (BT Secure + * Simple Pairing) requires a little endian. At the same time, + * the NDEF forum NDEF spec define a payload length as single + * byte (and the payload size IS the oob data size). + */ + bt_oob_data_size = near_get_le16(ptr); + if (bt_oob_data_size > 0xFF) /* Big Endian */ + bt_oob_data_size = GUINT16_FROM_BE(bt_oob_data_size); + + bt_oob_data_size -= 2 ; /* remove oob datas size len */ + + /* First item: BD_ADDR (mandatory) */ + ptr = &data->data[2]; + oob->bd_addr = g_strdup_printf("%02X:%02X:%02X:%02X:%02X:%02X", + ptr[5], ptr[4], ptr[3], ptr[2], ptr[1], ptr[0]); + + /* Skip to the next element (optional) */ + ptr += BT_ADDRESS_SIZE; + bt_oob_data_size -= BT_ADDRESS_SIZE ; + + if (bt_oob_data_size) + bt_parse_eir(ptr, bt_oob_data_size, oob, + mime_properties); + } else if (data->type == BT_MIME_V2_0) { + marker = *ptr++; /* could be '$' */ + + oob->bd_addr = g_strdup_printf( + "%02X:%02X:%02X:%02X:%02X:%02X", + ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); + ptr = ptr + BT_ADDRESS_SIZE; + + /* Class of device */ + tmp = g_strdup_printf("%02X%02X%02X", + *ptr, *(ptr + 1), *(ptr + 2)); + if (tmp) + oob->class_of_device = strtol(tmp, NULL, 16); + g_free(tmp); + + ptr = ptr + 3; + + /* "Short mode" seems to use a 4 bytes code + * instead of 16 bytes... + */ + if (marker == '$') { /* Short NFC */ + memcpy(oob->authentication, ptr, 4); + ptr = ptr + 4; + } else { + memcpy(oob->authentication, ptr, 16); + ptr = ptr + 16; + } + + /* get the device name */ + oob->bt_name_len = *ptr++; + oob->bt_name = g_try_malloc0(oob->bt_name_len+1); + if (oob->bt_name) { + memcpy(oob->bt_name, ptr, oob->bt_name_len); + oob->bt_name[oob->bt_name_len+1] = 0; + } + ptr = ptr + oob->bt_name_len; + } else { + bt_eir_free(oob); + return -EINVAL; + } + + if (!pair) { + bt_eir_free(oob); + return 0; + } + + /* check and get the default adapter */ + oob->def_adapter = g_strdup(bt_def_oob_data.def_adapter); + if (!oob->def_adapter) { + near_error("bt_get_default_adapter failed"); + bt_eir_free(oob); + return -EIO; + } + + return bt_do_pairing(oob); +} + +int __near_bluetooth_pair(void *data) +{ + struct near_oob_data *oob = data; + + /* check and get the default adapter */ + oob->def_adapter = g_strdup(bt_def_oob_data.def_adapter); + if (!oob->bt_name) { + near_error("bt_get_default_adapter failed: %d", -EIO); + bt_eir_free(oob); + return -EIO; + } + + return bt_do_pairing(oob); +} + +/* This function is synchronous as oob datas change on each session */ +static int bt_sync_oob_readlocaldata(DBusConnection *conn, char *adapter_path, + char *spair_hash, + char *spair_randomizer) +{ + DBusMessage *message, *reply; + DBusError error; + int hash_len, rndm_len; + + message = dbus_message_new_method_call(BLUEZ_SERVICE, adapter_path, + OOB_INTF, "ReadLocalData"); + if (!message) + return 0; + + dbus_error_init(&error); + + reply = dbus_connection_send_with_reply_and_block(conn, + message, -1, &error); + + dbus_message_unref(message); + + if (!reply) { + if (dbus_error_is_set(&error)) { + near_error("%s", error.message); + dbus_error_free(&error); + } else { + near_error("Failed to set property"); + } + return 0; + } + + if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE, spair_hash, + &hash_len, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE, spair_randomizer, + &rndm_len, DBUS_TYPE_INVALID)) + goto done; + + if ((hash_len != OOB_SP_SIZE) || (rndm_len != OOB_SP_SIZE)) { + DBG("no OOB data found !"); + goto done; + } + + dbus_message_unref(reply); + DBG("OOB data found"); + return hash_len; + +done: + dbus_message_unref(reply); + return 0; +} + +/* + * External API to get bt properties + * Prepare a "real" oob datas block + * mime_props is a bitmask we use to add or not specific fields in the + * oob frame (e.g.: OOB keys) + * */ +struct carrier_data *__near_bluetooth_local_get_properties(uint16_t mime_props) +{ + struct carrier_data *data = NULL; + uint8_t offset; + + char hash[OOB_SP_SIZE]; + char random[OOB_SP_SIZE]; + + /* Check adapter datas */ + if (!bt_def_oob_data.def_adapter) { + near_error("No bt adapter info"); + goto fail; + } + + data = g_try_malloc0(sizeof(*data)); + if (!data) + goto fail; + + data->size = sizeof(uint16_t) /* stored oob size */ + + BT_ADDRESS_SIZE; /* device address */ + + offset = sizeof(uint16_t); /* Skip size...will be filled later */ + + /* Now prepare data frame */ + memcpy(data->data + offset, bt_def_oob_data.bd_addr, BT_ADDRESS_SIZE); + offset += BT_ADDRESS_SIZE; + + /* CoD */ + data->size += COD_SIZE + EIR_HEADER_LEN; + + data->data[offset++] = COD_SIZE + EIR_SIZE_LEN; + data->data[offset++] = EIR_CLASS_OF_DEVICE; + + memcpy(data->data + offset, + (uint8_t *)&bt_def_oob_data.class_of_device, COD_SIZE); + offset += COD_SIZE; + + /* + * The following data are generated dynamically so we have to read the + * local oob data. Only add OOB pairing keys if needed. + */ + if ((mime_props & OOB_PROPS_SP) != 0 && + bt_sync_oob_readlocaldata(bt_conn, + bt_def_oob_data.def_adapter, + hash, random) == OOB_SP_SIZE) { + data->size += 2 * (OOB_SP_SIZE + EIR_HEADER_LEN); + + /* OOB datas */ + data->data[offset++] = OOB_SP_SIZE + EIR_SIZE_LEN; + data->data[offset++] = EIR_SP_HASH; + memcpy(data->data + offset, hash, OOB_SP_SIZE); + offset += OOB_SP_SIZE; + + data->data[offset++] = OOB_SP_SIZE + EIR_SIZE_LEN; + data->data[offset++] = EIR_SP_RANDOMIZER; + memcpy(data->data + offset, random, OOB_SP_SIZE); + offset += OOB_SP_SIZE; + } + + /* bt name */ + if (bt_def_oob_data.bt_name) { + int name_len; + + data->size += EIR_HEADER_LEN; + + if (data->size + bt_def_oob_data.bt_name_len + > EIR_SIZE_MAX) { + name_len = EIR_SIZE_MAX - data->size; + data->data[offset++] = name_len + EIR_SIZE_LEN; + /* EIR data type */ + data->data[offset++] = EIR_NAME_COMPLETE; + } else { + name_len = bt_def_oob_data.bt_name_len; + data->data[offset++] = name_len + EIR_SIZE_LEN; + /* EIR data type */ + data->data[offset++] = EIR_NAME_SHORT; + } + + data->size += name_len; + memcpy(data->data + offset, bt_def_oob_data.bt_name, name_len); + offset += name_len; + } + + data->data[0] = data->size ; + + if (bt_def_oob_data.powered) + data->state = CPS_ACTIVE; + else + data->state = CPS_INACTIVE; + + return data; + +fail: + g_free(data); + return NULL; +} + +/* BT adapter removed handler */ +static gboolean bt_adapter_removed(DBusConnection *conn, DBusMessage *message, + void *user_data) +{ + DBusMessageIter iter; + struct near_oob_data *bt_props = user_data; + const char *adapter_path; + + DBG(""); + + if (!bt_props->def_adapter) + return TRUE; + + g_dbus_remove_watch(bt_conn, adapter_props_watch); + adapter_props_watch = 0; + + if (!dbus_message_iter_init(message, &iter)) + return TRUE; + + dbus_message_iter_get_basic(&iter, &adapter_path); + + if (g_strcmp0(adapter_path, bt_props->def_adapter) == 0) { + near_info("Remove the default adapter [%s]", adapter_path); + + __bt_eir_free(bt_props); + bt_props->def_adapter = NULL; + } + + return TRUE; +} + +/* BT default adapter changed handler */ +static gboolean bt_default_adapter_changed(DBusConnection *conn, + DBusMessage *message, + void *user_data) +{ + struct near_oob_data *bt_props = user_data; + DBusMessageIter iter; + const char *adapter_path; + + DBG(""); + + if (!dbus_message_iter_init(message, &iter)) + return TRUE; + + g_dbus_remove_watch(bt_conn, adapter_props_watch); + adapter_props_watch = 0; + + dbus_message_iter_get_basic(&iter, &adapter_path); + DBG("New default adapter [%s]", adapter_path); + + /* Disable the old one */ + __bt_eir_free(bt_props); + bt_props->def_adapter = NULL; + + /* Refresh */ + bt_refresh_adapter_props(conn, user_data); + + return TRUE; +} + +static void bt_dbus_disconnect_cb(DBusConnection *conn, void *user_data) +{ + near_error("D-Bus disconnect (BT)"); + bt_conn = NULL; +} + +static gboolean register_bluez(gpointer user_data) +{ + DBG(""); + + register_bluez_timer = 0; + + removed_watch = g_dbus_add_signal_watch(bt_conn, NULL, NULL, + MANAGER_INTF, + ADAPTER_REMOVED, + bt_adapter_removed, + &bt_def_oob_data, NULL); + + + adapter_watch = g_dbus_add_signal_watch(bt_conn, NULL, NULL, + MANAGER_INTF, + DEFAULT_ADAPTER_CHANGED, + bt_default_adapter_changed, + &bt_def_oob_data, NULL); + + if (removed_watch == 0 || adapter_watch == 0) { + near_error("BlueZ event handlers failed to register."); + g_dbus_remove_watch(bt_conn, removed_watch); + g_dbus_remove_watch(bt_conn, adapter_watch); + + return FALSE; + } + + if (bt_refresh_adapter_props(bt_conn, user_data) < 0) + near_error("Failed to get BT adapter properties"); + + return FALSE; +} + +static void bt_connect(DBusConnection *conn, void *data) +{ + DBG("connection %p with %p", conn, data); + + if (__near_agent_handover_registered(HO_AGENT_BT)) { + DBG("Agent already registered"); + return; + } + + /* + * BlueZ 5 will register itself as HandoverAgent, give it some time + * to do it before going legacy way. + */ + register_bluez_timer = g_timeout_add_seconds(AGENT_REGISTER_TIMEOUT, + register_bluez, data); +} + +static void bt_disconnect(DBusConnection *conn, void *user_data) +{ + DBG("%p", conn); + + /* If timer is running no BlueZ watchers were registered yet */ + if (register_bluez_timer > 0) { + g_source_remove(register_bluez_timer); + register_bluez_timer = 0; + return; + } + + __bt_eir_free(user_data); + + g_dbus_remove_watch(bt_conn, removed_watch); + removed_watch = 0; + + g_dbus_remove_watch(bt_conn, adapter_watch); + adapter_watch = 0; + + g_dbus_remove_watch(bt_conn, adapter_props_watch); + adapter_props_watch = 0; +} + +static int bt_prepare_handlers(DBusConnection *conn) +{ + if (__near_agent_handover_registered(HO_AGENT_BT)) + return 0; + + watch = g_dbus_add_service_watch(bt_conn, BLUEZ_SERVICE, + bt_connect, + bt_disconnect, + &bt_def_oob_data, NULL); + if (watch == 0) { + near_error("BlueZ service watch handler failed to register."); + g_dbus_remove_watch(bt_conn, watch); + return -EIO; + } + + return 0; +} + +void __near_bluetooth_legacy_start(void) +{ + DBG(""); + + bt_prepare_handlers(bt_conn); +} + +void __near_bluetooth_legacy_stop(void) +{ + DBG(""); + + g_dbus_remove_watch(bt_conn, watch); + watch = 0; + + bt_disconnect(bt_conn, &bt_def_oob_data); +} + +/* Bluetooth exiting function */ +void __near_bluetooth_cleanup(void) +{ + DBG(""); + + if (!bt_conn) + return; + + __near_bluetooth_legacy_stop(); + + dbus_connection_unref(bt_conn); +} + +/* + * Bluetooth initialization function. + * Allocate bt local settings storage + * and setup event handlers + */ +int __near_bluetooth_init(void) +{ + DBusError err; + + DBG(""); + + dbus_error_init(&err); + + /* save the dbus connection */ + bt_conn = near_dbus_get_connection(); + if (!bt_conn) { + if (dbus_error_is_set(&err)) { + near_error("%s", err.message); + dbus_error_free(&err); + } else + near_error("Can't register with system bus\n"); + return -EIO; + } + + /* dbus disconnect callback */ + g_dbus_set_disconnect_function(bt_conn, bt_dbus_disconnect_cb, + NULL, NULL); + + /* Set bluez event handlers */ + return bt_prepare_handlers(bt_conn); +}
diff --git a/neard/src/dbus.c b/neard/src/dbus.c new file mode 100644 index 0000000..9c67a9e --- /dev/null +++ b/neard/src/dbus.c
@@ -0,0 +1,298 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <string.h> +#include <gdbus.h> + +#include "near.h" + +static DBusConnection *connection; + +dbus_bool_t near_dbus_validate_ident(const char *ident) +{ + unsigned int i; + + if (!ident) + return FALSE; + + for (i = 0; i < strlen(ident); i++) { + if (ident[i] >= '0' && ident[i] <= '9') + continue; + if (ident[i] >= 'a' && ident[i] <= 'z') + continue; + if (ident[i] >= 'A' && ident[i] <= 'Z') + continue; + return FALSE; + } + + return TRUE; +} + +char *near_dbus_encode_string(const char *value) +{ + GString *str; + unsigned int i, size; + + if (!value) + return NULL; + + size = strlen(value); + + str = g_string_new(NULL); + if (!str) + return NULL; + + for (i = 0; i < size; i++) { + const char tmp = value[i]; + if ((tmp < '0' || tmp > '9') && (tmp < 'A' || tmp > 'Z') && + (tmp < 'a' || tmp > 'z')) + g_string_append_printf(str, "_%02x", tmp); + else + str = g_string_append_c(str, tmp); + } + + return g_string_free(str, FALSE); +} + +void near_dbus_property_append_basic(DBusMessageIter *iter, + const char *key, int type, void *val) +{ + DBusMessageIter value; + const char *signature; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key); + + switch (type) { + case DBUS_TYPE_BOOLEAN: + signature = DBUS_TYPE_BOOLEAN_AS_STRING; + break; + case DBUS_TYPE_STRING: + signature = DBUS_TYPE_STRING_AS_STRING; + break; + case DBUS_TYPE_BYTE: + signature = DBUS_TYPE_BYTE_AS_STRING; + break; + case DBUS_TYPE_UINT16: + signature = DBUS_TYPE_UINT16_AS_STRING; + break; + case DBUS_TYPE_INT16: + signature = DBUS_TYPE_INT16_AS_STRING; + break; + case DBUS_TYPE_UINT32: + signature = DBUS_TYPE_UINT32_AS_STRING; + break; + case DBUS_TYPE_INT32: + signature = DBUS_TYPE_INT32_AS_STRING; + break; + case DBUS_TYPE_OBJECT_PATH: + signature = DBUS_TYPE_OBJECT_PATH_AS_STRING; + break; + default: + signature = DBUS_TYPE_VARIANT_AS_STRING; + break; + } + + dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, + signature, &value); + dbus_message_iter_append_basic(&value, type, val); + dbus_message_iter_close_container(iter, &value); +} + +void near_dbus_property_append_dict(DBusMessageIter *iter, const char *key, + near_dbus_append_cb_t function, void *user_data) +{ + DBusMessageIter value, dict; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key); + + dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, + DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &value); + + near_dbus_dict_open(&value, &dict); + if (function) + function(&dict, user_data); + near_dbus_dict_close(&value, &dict); + + dbus_message_iter_close_container(iter, &value); +} + +void near_dbus_property_append_fixed_array(DBusMessageIter *iter, + const char *key, int type, void *val, int len) +{ + DBusMessageIter value, array; + const char *variant_sig, *array_sig; + + switch (type) { + case DBUS_TYPE_BYTE: + variant_sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING; + array_sig = DBUS_TYPE_BYTE_AS_STRING; + break; + default: + return; + } + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key); + + dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, + variant_sig, &value); + + dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, + array_sig, &array); + dbus_message_iter_append_fixed_array(&array, type, val, len); + dbus_message_iter_close_container(&value, &array); + + dbus_message_iter_close_container(iter, &value); +} + +void near_dbus_property_append_array(DBusMessageIter *iter, + const char *key, int type, + near_dbus_append_cb_t function, void *user_data) +{ + DBusMessageIter value, array; + const char *variant_sig, *array_sig; + + switch (type) { + case DBUS_TYPE_STRING: + variant_sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING; + array_sig = DBUS_TYPE_STRING_AS_STRING; + break; + case DBUS_TYPE_OBJECT_PATH: + variant_sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING; + array_sig = DBUS_TYPE_OBJECT_PATH_AS_STRING; + break; + case DBUS_TYPE_BYTE: + variant_sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING; + array_sig = DBUS_TYPE_BYTE_AS_STRING; + break; + default: + return; + } + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key); + + dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, + variant_sig, &value); + + dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, + array_sig, &array); + if (function) + function(&array, user_data); + dbus_message_iter_close_container(&value, &array); + + dbus_message_iter_close_container(iter, &value); +} + +static DBusConnection *connection = NULL; + +dbus_bool_t near_dbus_property_changed_basic(const char *path, + const char *interface, const char *key, + int type, void *val) +{ + DBusMessage *signal; + DBusMessageIter iter; + + if (!path) + return FALSE; + + signal = dbus_message_new_signal(path, interface, "PropertyChanged"); + if (!signal) + return FALSE; + + dbus_message_iter_init_append(signal, &iter); + near_dbus_property_append_basic(&iter, key, type, val); + + g_dbus_send_message(connection, signal); + + return TRUE; +} + +dbus_bool_t near_dbus_property_changed_dict(const char *path, + const char *interface, const char *key, + near_dbus_append_cb_t function, void *user_data) +{ + DBusMessage *signal; + DBusMessageIter iter; + + if (!path) + return FALSE; + + signal = dbus_message_new_signal(path, interface, "PropertyChanged"); + if (!signal) + return FALSE; + + dbus_message_iter_init_append(signal, &iter); + near_dbus_property_append_dict(&iter, key, function, user_data); + + g_dbus_send_message(connection, signal); + + return TRUE; +} + +dbus_bool_t near_dbus_property_changed_array(const char *path, + const char *interface, const char *key, int type, + near_dbus_append_cb_t function, void *user_data) +{ + DBusMessage *signal; + DBusMessageIter iter; + + if (!path) + return FALSE; + + signal = dbus_message_new_signal(path, interface, "PropertyChanged"); + if (!signal) + return FALSE; + + dbus_message_iter_init_append(signal, &iter); + near_dbus_property_append_array(&iter, key, type, + function, user_data); + + g_dbus_send_message(connection, signal); + + return TRUE; +} + +DBusConnection *near_dbus_get_connection(void) +{ + return connection; +} + +int __near_dbus_init(DBusConnection *conn) +{ + DBG(""); + + connection = conn; + + return 0; +} + +void __near_dbus_cleanup(void) +{ + DBG(""); + + connection = NULL; +}
diff --git a/neard/src/device.c b/neard/src/device.c new file mode 100644 index 0000000..a6598e0 --- /dev/null +++ b/neard/src/device.c
@@ -0,0 +1,466 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <string.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "near.h" + +struct near_device { + char *path; + + uint32_t adapter_idx; + uint32_t target_idx; + + uint8_t nfcid[NFC_MAX_NFCID1_LEN]; + uint8_t nfcid_len; + + size_t data_length; + uint8_t *data; + + uint32_t n_records; + GList *records; + + DBusMessage *push_msg; /* Push pending message */ +}; + +static DBusConnection *connection = NULL; + +static GHashTable *device_hash; + +static GSList *driver_list = NULL; + +static void free_device(gpointer data) +{ + struct near_device *device = data; + + DBG("device %p", device); + + near_ndef_records_free(device->records); + + g_dbus_unregister_interface(connection, device->path, + NFC_DEVICE_INTERFACE); + + g_free(device->path); + g_free(device->data); + g_free(device); +} + +struct near_device *near_device_get_device(uint32_t adapter_idx, + uint32_t target_idx) +{ + struct near_device *device; + char *path; + + DBG(""); + + path = g_strdup_printf("%s/nfc%d/device%d", NFC_PATH, + adapter_idx, target_idx); + if (!path) + return NULL; + + device = g_hash_table_lookup(device_hash, path); + g_free(path); + + /* TODO refcount */ + return device; +} + +const char *__near_device_get_path(struct near_device *device) +{ + return device->path; +} + +uint32_t __neard_device_get_idx(struct near_device *device) +{ + return device->target_idx; +} + +static void push_cb(uint32_t adapter_idx, uint32_t target_idx, int status) +{ + struct near_device *device; + DBusConnection *conn; + DBusMessage *reply; + + DBG("Push status %d", status); + + conn = near_dbus_get_connection(); + device = near_device_get_device(adapter_idx, target_idx); + + if (!conn || !device) + return; + + if (status != 0) { + reply = __near_error_failed(device->push_msg, -status); + if (reply) + g_dbus_send_message(conn, reply); + } else { + g_dbus_send_reply(conn, device->push_msg, DBUS_TYPE_INVALID); + } + + dbus_message_unref(device->push_msg); + device->push_msg = NULL; +} + +static char *sn_from_message(DBusMessage *msg) +{ + DBusMessageIter iter; + DBusMessageIter arr_iter; + + DBG(""); + + dbus_message_iter_init(msg, &iter); + dbus_message_iter_recurse(&iter, &arr_iter); + + while (dbus_message_iter_get_arg_type(&arr_iter) != + DBUS_TYPE_INVALID) { + const char *key, *value; + DBusMessageIter ent_iter; + DBusMessageIter var_iter; + + dbus_message_iter_recurse(&arr_iter, &ent_iter); + dbus_message_iter_get_basic(&ent_iter, &key); + + if (g_strcmp0(key, "Type") != 0) { + dbus_message_iter_next(&arr_iter); + continue; + } + + dbus_message_iter_next(&ent_iter); + dbus_message_iter_recurse(&ent_iter, &var_iter); + + switch (dbus_message_iter_get_arg_type(&var_iter)) { + case DBUS_TYPE_STRING: + dbus_message_iter_get_basic(&var_iter, &value); + + if (g_strcmp0(value, "Text") == 0) + return NEAR_DEVICE_SN_SNEP; + else if (g_strcmp0(value, "URI") == 0) + return NEAR_DEVICE_SN_SNEP; + else if (g_strcmp0(value, "SmartPoster") == 0) + return NEAR_DEVICE_SN_SNEP; + else if (g_strcmp0(value, "Handover") == 0) + return NEAR_DEVICE_SN_HANDOVER; + else if (g_strcmp0(value, "StaticHandover") == 0) + return NEAR_DEVICE_SN_HANDOVER; + else if (g_strcmp0(value, "MIME") == 0) + return NEAR_DEVICE_SN_SNEP; + else + return NULL; + + break; + } + + dbus_message_iter_next(&arr_iter); + } + + return NULL; +} + +static DBusMessage *push_ndef(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct near_device *device = data; + struct near_ndef_message *ndef; + char *service_name; + int err; + + DBG("conn %p", conn); + + if (device->push_msg) + return __near_error_in_progress(msg); + + device->push_msg = dbus_message_ref(msg); + + service_name = sn_from_message(msg); + if (!service_name) { + err = -EINVAL; + goto error; + } + + ndef = __ndef_build_from_message(msg); + if (!ndef) { + err = -EINVAL; + goto error; + } + + err = __near_device_push(device, ndef, service_name, push_cb); + if (err < 0) + goto error; + + return NULL; + +error: + dbus_message_unref(device->push_msg); + device->push_msg = NULL; + + return __near_error_failed(msg, -err); +} + +static gboolean property_get_adapter(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_device *device = user_data; + struct near_adapter *adapter; + const char *path; + + adapter = __near_adapter_get(device->adapter_idx); + if (!adapter) + return FALSE; + + path = __near_adapter_get_path(adapter); + if (!path) + return FALSE; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); + + return TRUE; + +} + +static const GDBusMethodTable device_methods[] = { + { GDBUS_ASYNC_METHOD("Push", GDBUS_ARGS({"attributes", "a{sv}"}), + NULL, push_ndef) }, + { }, +}; + +static const GDBusPropertyTable device_properties[] = { + { "Adapter", "o", property_get_adapter }, + + { } +}; + +void __near_device_remove(struct near_device *device) +{ + char *path = device->path; + + DBG("path %s", device->path); + + if (device->push_msg) + push_cb(device->adapter_idx, device->target_idx, EIO); + + g_hash_table_remove(device_hash, path); +} + +int near_device_add_data(uint32_t adapter_idx, uint32_t target_idx, + uint8_t *data, size_t data_length) +{ + struct near_device *device; + + device = near_device_get_device(adapter_idx, target_idx); + if (!device) + return -ENODEV; + + device->data_length = data_length; + device->data = g_try_malloc0(data_length); + if (!device->data) + return -ENOMEM; + + if (data) + memcpy(device->data, data, data_length); + + return 0; +} + +int near_device_add_records(struct near_device *device, GList *records, + near_device_io_cb cb, int status) +{ + GList *list; + struct near_ndef_record *record; + char *path; + + DBG("records %p", records); + + near_ndef_records_free(device->records); + device->records = NULL; + + for (list = records; list; list = list->next) { + record = list->data; + + path = g_strdup_printf("%s/nfc%d/device%d/record%d", + NFC_PATH, device->adapter_idx, + device->target_idx, device->n_records); + + if (!path) + continue; + + __near_ndef_record_register(record, path); + + device->n_records++; + device->records = g_list_append(device->records, record); + } + + __near_agent_ndef_parse_records(device->records); + + if (cb) + cb(device->adapter_idx, device->target_idx, status); + + g_list_free(records); + + return 0; +} + +struct near_device *__near_device_add(uint32_t adapter_idx, uint32_t target_idx, + uint8_t *nfcid, uint8_t nfcid_len) +{ + struct near_device *device; + char *path; + + device = near_device_get_device(adapter_idx, target_idx); + if (device) + return NULL; + + device = g_try_malloc0(sizeof(struct near_device)); + if (!device) + return NULL; + + device->path = g_strdup_printf("%s/nfc%d/device%d", NFC_PATH, + adapter_idx, target_idx); + if (!device->path) { + g_free(device); + return NULL; + } + device->adapter_idx = adapter_idx; + device->target_idx = target_idx; + device->n_records = 0; + + if (nfcid_len <= NFC_MAX_NFCID1_LEN && nfcid_len > 0) { + device->nfcid_len = nfcid_len; + memcpy(device->nfcid, nfcid, nfcid_len); + } + + path = g_strdup(device->path); + if (!path) { + g_free(device); + return NULL; + } + + g_hash_table_insert(device_hash, path, device); + + return device; +} + +bool __near_device_register_interface(struct near_device *device) +{ + DBG("connection %p", connection); + + return g_dbus_register_interface(connection, device->path, + NFC_DEVICE_INTERFACE, + device_methods, NULL, + device_properties, device, NULL); +} + +int __near_device_listen(struct near_device *device, near_device_io_cb cb) +{ + GSList *list; + + DBG(""); + + for (list = driver_list; list; list = list->next) { + struct near_device_driver *driver = list->data; + + return driver->listen(device->adapter_idx, cb); + } + + return 0; +} + +int __near_device_push(struct near_device *device, + struct near_ndef_message *ndef, char *service_name, + near_device_io_cb cb) +{ + GSList *list; + + DBG(""); + + if (!__near_adapter_get_dep_state(device->adapter_idx)) { + near_error("DEP link is not established"); + return -ENOLINK; + } + + for (list = driver_list; list; list = list->next) { + struct near_device_driver *driver = list->data; + + return driver->push(device->adapter_idx, device->target_idx, + ndef, service_name, cb); + } + + return 0; +} + +static gint cmp_prio(gconstpointer a, gconstpointer b) +{ + const struct near_tag_driver *driver1 = a; + const struct near_tag_driver *driver2 = b; + + return driver2->priority - driver1->priority; +} + +int near_device_driver_register(struct near_device_driver *driver) +{ + DBG(""); + + if (!driver->listen) + return -EINVAL; + + driver_list = g_slist_insert_sorted(driver_list, driver, cmp_prio); + + __near_adapter_listen(driver); + + return 0; +} + +void near_device_driver_unregister(struct near_device_driver *driver) +{ + DBG(""); + + driver_list = g_slist_remove(driver_list, driver); +} + +int __near_device_init(void) +{ + DBG(""); + + connection = near_dbus_get_connection(); + + device_hash = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, free_device); + + return 0; +} + +void __near_device_cleanup(void) +{ + DBG(""); + + g_hash_table_destroy(device_hash); + device_hash = NULL; +}
diff --git a/neard/src/error.c b/neard/src/error.c new file mode 100644 index 0000000..a9d2d43 --- /dev/null +++ b/neard/src/error.c
@@ -0,0 +1,215 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <errno.h> +#include <string.h> + +#include <gdbus.h> + +#include "near.h" + +DBusMessage *__near_error_failed(DBusMessage *msg, int errnum) +{ + const char *str = strerror(errnum); + + switch (errnum) { + case ESRCH: + return __near_error_not_registered(msg); + case ENXIO: + return __near_error_not_found(msg); + case ENOMEM: + return __near_error_out_of_memory(msg); + case EACCES: + return __near_error_permission_denied(msg); + case EEXIST: + return __near_error_already_exists(msg); + case EINVAL: + return __near_error_invalid_arguments(msg); + case EIO: + return __near_error_io_error(msg); + case ENOSYS: + return __near_error_not_implemented(msg); + case ENOLINK: + return __near_error_no_carrier(msg); + case ENOTUNIQ: + return __near_error_not_unique(msg); + case EOPNOTSUPP: + return __near_error_not_supported(msg); + case ECONNABORTED: + return __near_error_operation_aborted(msg); + case EISCONN: + return __near_error_already_connected(msg); + case ENOTCONN: + return __near_error_not_connected(msg); + case ETIMEDOUT: + return __near_error_operation_timeout(msg); + case EALREADY: + return __near_error_in_progress(msg); + case ENOKEY: + return __near_error_passphrase_required(msg); + case ENOSPC: + return __near_error_no_space_left(msg); + } + + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".Failed", "%s", str); +} + +DBusMessage *__near_error_invalid_arguments(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".InvalidArguments", "Invalid arguments"); +} + +DBusMessage *__near_error_out_of_memory(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".OutOfMemory", "Out of memory"); +} + +DBusMessage *__near_error_permission_denied(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".PermissionDenied", "Permission denied"); +} + +DBusMessage *__near_error_passphrase_required(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".PassphraseRequired", "Passphrase required"); +} + +DBusMessage *__near_error_not_registered(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".NotRegistered", "Not registered"); +} + +DBusMessage *__near_error_not_unique(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".NotUnique", "Not unique"); +} + +DBusMessage *__near_error_not_supported(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".NotSupported", "Not supported"); +} + +DBusMessage *__near_error_not_implemented(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".NotImplemented", "Not implemented"); +} + +DBusMessage *__near_error_not_found(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".NotFound", "Not found"); +} + +DBusMessage *__near_error_not_polling(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".Failed", "Not polling"); +} + +DBusMessage *__near_error_no_carrier(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".NoCarrier", "No carrier"); +} + +DBusMessage *__near_error_in_progress(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".InProgress", "In progress"); +} + +DBusMessage *__near_error_already_exists(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".AlreadyExists", "Already exists"); +} + +DBusMessage *__near_error_already_enabled(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".AlreadyEnabled", "Already enabled"); +} + +DBusMessage *__near_error_already_disabled(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".AlreadyDisabled", "Already disabled"); +} + +DBusMessage *__near_error_already_connected(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".AlreadyConnected", "Already connected"); +} + +DBusMessage *__near_error_not_connected(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".NotConnected", "Not connected"); +} +DBusMessage *__near_error_operation_aborted(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".OperationAborted", "Operation aborted"); +} + +DBusMessage *__near_error_operation_timeout(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".OperationTimeout", "Operation timeout"); +} + +DBusMessage *__near_error_invalid_service(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".InvalidService", "Invalid service"); +} + +DBusMessage *__near_error_invalid_property(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".InvalidProperty", "Invalid property"); +} + +DBusMessage *__near_error_io_error(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".IOError", "I/O Error"); +} + +DBusMessage *__near_error_no_space_left(DBusMessage *msg) +{ + return g_dbus_create_error(msg, NFC_ERROR_INTERFACE + ".NoSpaceLeft", "No space left"); +}
diff --git a/neard/src/genbuiltin b/neard/src/genbuiltin new file mode 100755 index 0000000..9c2ba15 --- /dev/null +++ b/neard/src/genbuiltin
@@ -0,0 +1,17 @@ +#!/bin/sh + +for i in $* +do + echo "extern struct near_plugin_desc __near_builtin_$i;" +done + +echo +echo "static struct near_plugin_desc *__near_builtin[] = {" + +for i in $* +do + echo " &__near_builtin_$i," +done + +echo " NULL" +echo "};"
diff --git a/neard/src/log.c b/neard/src/log.c new file mode 100644 index 0000000..74e748a --- /dev/null +++ b/neard/src/log.c
@@ -0,0 +1,138 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdarg.h> +#include <syslog.h> + +#include "near.h" + +void near_info(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + vsyslog(LOG_INFO, format, ap); + + va_end(ap); +} + +void near_warn(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + vsyslog(LOG_WARNING, format, ap); + + va_end(ap); +} + +void near_error(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + vsyslog(LOG_ERR, format, ap); + + va_end(ap); +} + +void near_debug(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + vsyslog(LOG_DEBUG, format, ap); + + va_end(ap); +} + +extern struct near_debug_desc __start___debug[]; +extern struct near_debug_desc __stop___debug[]; + +static gchar **enabled = NULL; + +static bool is_enabled(struct near_debug_desc *desc) +{ + int i; + + if (!enabled) + return false; + + for (i = 0; enabled[i]; i++) { + if (desc->name && g_pattern_match_simple(enabled[i], + desc->name)) + return true; + if (desc->file && g_pattern_match_simple(enabled[i], + desc->file)) + return true; + } + + return false; +} + +int __near_log_init(const char *debug, gboolean detach) +{ + int option = LOG_NDELAY | LOG_PID; + struct near_debug_desc *desc; + const char *name = NULL, *file = NULL; + + if (debug) + enabled = g_strsplit_set(debug, ":, ", 0); + + for (desc = __start___debug; desc < __stop___debug; desc++) { + if (file || name) { + if (g_strcmp0(desc->file, file) == 0) { + if (!desc->name) + desc->name = name; + } else + file = NULL; + } + + if (is_enabled(desc)) + desc->flags |= NEAR_DEBUG_FLAG_PRINT; + } + + if (!detach) + option |= LOG_PERROR; + + openlog("neard", option, LOG_DAEMON); + + syslog(LOG_INFO, "NEAR daemon version %s", VERSION); + + return 0; +} + +void __near_log_cleanup(void) +{ + syslog(LOG_INFO, "Exit"); + + closelog(); + + g_strfreev(enabled); +}
diff --git a/neard/src/main.c b/neard/src/main.c new file mode 100644 index 0000000..a2c3a84 --- /dev/null +++ b/neard/src/main.c
@@ -0,0 +1,327 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <signal.h> +#include <sys/signalfd.h> + +#include <gdbus.h> + +#include "near.h" + +static struct { + bool constant_poll; + bool default_powered; + bool reset_on_error; +} near_settings = { + .constant_poll = FALSE, + .default_powered = FALSE, + .reset_on_error = TRUE, +}; + +static GKeyFile *load_config(const char *file) +{ + GError *err = NULL; + GKeyFile *keyfile; + + keyfile = g_key_file_new(); + + g_key_file_set_list_separator(keyfile, ','); + + if (!g_key_file_load_from_file(keyfile, file, 0, &err)) { + if (err->code != G_FILE_ERROR_NOENT) { + near_error("Parsing %s failed: %s", file, + err->message); + } + + g_error_free(err); + g_key_file_free(keyfile); + return NULL; + } + + return keyfile; +} + +static void parse_config(GKeyFile *config) +{ + GError *error = NULL; + bool boolean; + + if (!config) + return; + + DBG("parsing main.conf"); + + boolean = g_key_file_get_boolean(config, "General", + "ConstantPoll", &error); + if (!error) + near_settings.constant_poll = boolean; + + boolean = g_key_file_get_boolean(config, "General", + "DefaultPowered", &error); + if (!error) + near_settings.default_powered = boolean; + + boolean = g_key_file_get_boolean(config, "General", + "ResetOnError", &error); + if (!error) + near_settings.reset_on_error = boolean; + + g_clear_error(&error); +} + +static GMainLoop *main_loop = NULL; + +static volatile sig_atomic_t __terminated = 0; + +static gboolean signal_handler(GIOChannel *channel, GIOCondition cond, + gpointer user_data) +{ + struct signalfd_siginfo si; + ssize_t result; + int fd; + + if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) + return FALSE; + + fd = g_io_channel_unix_get_fd(channel); + + result = read(fd, &si, sizeof(si)); + if (result != sizeof(si)) + return FALSE; + + switch (si.ssi_signo) { + case SIGINT: + case SIGTERM: + if (__terminated == 0) { + near_info("Terminating"); + g_main_loop_quit(main_loop); + } + + __terminated = 1; + break; + } + + return TRUE; +} + +static guint setup_signalfd(void) +{ + GIOChannel *channel; + guint source; + sigset_t mask; + int fd; + + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGTERM); + + if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0) { + perror("Failed to set signal mask"); + return 0; + } + + fd = signalfd(-1, &mask, 0); + if (fd < 0) { + perror("Failed to create signal descriptor"); + return 0; + } + + channel = g_io_channel_unix_new(fd); + + g_io_channel_set_close_on_unref(channel, TRUE); + g_io_channel_set_encoding(channel, NULL, NULL); + g_io_channel_set_buffered(channel, FALSE); + + source = g_io_add_watch(channel, + G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, + signal_handler, NULL); + + g_io_channel_unref(channel); + + return source; +} + +static void disconnect_callback(DBusConnection *conn, void *user_data) +{ + near_error("D-Bus disconnect"); + + g_main_loop_quit(main_loop); +} + +static gchar *option_debug = NULL; +static gchar *option_plugin = NULL; +static gchar *option_noplugin = NULL; +static gboolean option_detach = TRUE; +static gboolean option_version = FALSE; + +static bool parse_debug(const char *key, const char *value, + gpointer user_data, GError **error) +{ + if (value) + option_debug = g_strdup(value); + else + option_debug = g_strdup("*"); + + return true; +} + +static GOptionEntry options[] = { + { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG, + G_OPTION_ARG_CALLBACK, parse_debug, + "Specify debug options to enable", "DEBUG" }, + { "nodaemon", 'n', G_OPTION_FLAG_REVERSE, + G_OPTION_ARG_NONE, &option_detach, + "Don't fork daemon to background" }, + { "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin, + "Specify plugins to load", "NAME,..." }, + { "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin, + "Specify plugins not to load", "NAME,..." }, + { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version, + "Show version information and exit" }, + { NULL }, +}; + +bool near_setting_get_bool(const char *key) +{ + if (g_str_equal(key, "ConstantPoll")) + return near_settings.constant_poll; + + if (g_str_equal(key, "DefaultPowered")) + return near_settings.default_powered; + + if (g_str_equal(key, "ResetOnError")) + return near_settings.reset_on_error; + + return false; +} + +int main(int argc, char *argv[]) +{ + GOptionContext *context; + GError *error = NULL; + DBusConnection *conn; + DBusError err; + GKeyFile *config; + guint signal; + + context = g_option_context_new(NULL); + g_option_context_add_main_entries(context, options, NULL); + + if (!g_option_context_parse(context, &argc, &argv, &error)) { + if (error) { + g_printerr("%s\n", error->message); + g_error_free(error); + } else + g_printerr("An unknown error occurred\n"); + exit(1); + } + + g_option_context_free(context); + + if (option_version) { + printf("%s\n", VERSION); + exit(0); + } + + main_loop = g_main_loop_new(NULL, FALSE); + + signal = setup_signalfd(); + + dbus_error_init(&err); + + conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NFC_SERVICE, &err); + if (!conn) { + if (dbus_error_is_set(&err)) { + fprintf(stderr, "%s\n", err.message); + dbus_error_free(&err); + } else + fprintf(stderr, "Can't register with system bus\n"); + exit(1); + } + + g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); + + __near_log_init(option_debug, option_detach); + __near_dbus_init(conn); + + config = load_config(CONFIGDIR "/main.conf"); + + parse_config(config); + + if (__near_netlink_init() < 0) { + near_error("*** NETLINK INITIALIZATION FAILED ***"); + exit(1); + } + + __near_agent_init(); + __near_tag_init(); + __near_device_init(); + __near_adapter_init(); + __near_ndef_init(); + __near_snep_core_init(); + __near_manager_init(conn); + __near_bluetooth_init(); + + __near_plugin_init(option_plugin, option_noplugin); + + if (option_detach) { + if (daemon(0, 0)) { + perror("Can't start daemon"); + exit(1); + } + } + + g_main_loop_run(main_loop); + + g_source_remove(signal); + + __near_plugin_cleanup(); + + __near_bluetooth_cleanup(); + __near_manager_cleanup(); + __near_ndef_cleanup(); + __near_snep_core_cleanup(); + __near_adapter_cleanup(); + __near_device_cleanup(); + __near_tag_cleanup(); + __near_agent_cleanup(); + __near_netlink_cleanup(); + + __near_dbus_cleanup(); + __near_log_cleanup(); + + dbus_connection_unref(conn); + + g_main_loop_unref(main_loop); + + if (config) + g_key_file_free(config); + + return 0; +}
diff --git a/neard/src/main.conf b/neard/src/main.conf new file mode 100644 index 0000000..70c2697 --- /dev/null +++ b/neard/src/main.conf
@@ -0,0 +1,16 @@ +[General] + +# Enable constant polling. Default value is false. +# Constant polling will automatically trigger a new +# polling loop whenever a tag or a device is no longer +# in the RF field. +ConstantPoll = true + +# Automatically turn an adapter on when being discovered. +# Default value is false. +DefaultPowered = true + +# Power cycle the adapter when getting a driver error from +# the kernel. +# Default value is true. +ResetOnError = true
diff --git a/neard/src/manager.c b/neard/src/manager.c new file mode 100644 index 0000000..e4b72a7 --- /dev/null +++ b/neard/src/manager.c
@@ -0,0 +1,102 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "near.h" + +static DBusConnection *connection; + +int __near_manager_adapter_add(uint32_t idx, const char *name, + uint32_t protocols, bool powered) +{ + struct near_adapter *adapter; + const char *path; + int err; + + DBG("idx %d", idx); + + adapter = __near_adapter_create(idx, name, protocols, powered); + if (!adapter) + return -ENOMEM; + + path = __near_adapter_get_path(adapter); + if (!path) { + __near_adapter_destroy(adapter); + return -EINVAL; + } + + err = __near_adapter_add(adapter); + if (err < 0) + __near_adapter_destroy(adapter); + + return err; +} + +void __near_manager_adapter_remove(uint32_t idx) +{ + struct near_adapter *adapter; + const char *path; + + DBG("idx %d", idx); + + adapter = __near_adapter_get(idx); + if (!adapter) + return; + + path = __near_adapter_get_path(adapter); + if (!path) + return; + + __near_adapter_remove(adapter); +} + +int __near_manager_init(DBusConnection *conn) +{ + DBG(""); + + connection = dbus_connection_ref(conn); + + DBG("connection %p", connection); + + g_dbus_attach_object_manager(connection); + + return __near_netlink_get_adapters(); +} + +void __near_manager_cleanup(void) +{ + DBG(""); + + g_dbus_detach_object_manager(connection); + + dbus_connection_unref(connection); +}
diff --git a/neard/src/ndef.c b/neard/src/ndef.c new file mode 100644 index 0000000..d93a885 --- /dev/null +++ b/neard/src/ndef.c
@@ -0,0 +1,3750 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <string.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "near.h" + +enum record_tnf { + RECORD_TNF_EMPTY = 0x00, + RECORD_TNF_WELLKNOWN = 0x01, + RECORD_TNF_MIME = 0x02, + RECORD_TNF_URI = 0x03, + RECORD_TNF_EXTERNAL = 0x04, + RECORD_TNF_UNKNOWN = 0x05, + RECORD_TNF_UNCHANGED = 0x06, + RECORD_TNF_RESERVED = 0x07, +}; + +#define RECORD_ACTION_DO 0x00 +#define RECORD_ACTION_SAVE 0x01 +#define RECORD_ACTION_EDIT 0x02 + +#define RECORD_MB_BIT(val) ((val & 0x80) >> 7) +#define RECORD_ME_BIT(val) ((val & 0x40) >> 6) +#define RECORD_CF_BIT(val) ((val & 0x20) >> 5) +#define RECORD_SR_BIT(val) ((val & 0x10) >> 4) +#define RECORD_IL_BIT(val) ((val & 0x8) >> 3) +#define RECORD_TNF_BIT(val) (val & 0x7) + +#define NDEF_MSG_MIN_LENGTH 0x03 +#define NDEF_PAYLOAD_LENGTH_OFFSET 0x02 + +#define RECORD_MB 0x80 +#define RECORD_ME 0x40 +#define RECORD_CF 0x20 +#define RECORD_SR 0x10 +#define RECORD_IL 0x08 +#define RECORD_TNF_EMPTY_SET(val) ((val & ~0x7) | RECORD_TNF_EMPTY) +#define RECORD_TNF_WKT_SET(val) ((val & ~0x7) | RECORD_TNF_WELLKNOWN) +#define RECORD_TNF_MIME_SET(val) ((val & ~0x7) | RECORD_TNF_MIME) +#define RECORD_TNF_URI_SET(val) ((val & ~0x7) | RECORD_TNF_URI) +#define RECORD_TNF_EXTERNAL_SET(val) ((val & ~0x7) | RECORD_TNF_EXTERNAL) +#define RECORD_TNF_UKNOWN_SET(val) ((val & ~0x7) | RECORD_TNF_UNKNOWN) +#define RECORD_TNF_UNCHANGED_SET(val) ((val & ~0x7) | RECORD_TNF_UNCHANGED) + +#define NDEF_MSG_SHORT_RECORD_MAX_LENGTH 0xFF +#define NDEF_TEXT_RECORD_TYPE_NAME_HEX_VALUE 0x54 +#define NDEF_TEXT_RECORD_UTF16_STATUS 0x80 + +#define AC_CPS_MASK 0x03 + +enum record_type { + RECORD_TYPE_WKT_SMART_POSTER = 0x01, + RECORD_TYPE_WKT_URI = 0x02, + RECORD_TYPE_WKT_TEXT = 0x03, + RECORD_TYPE_WKT_SIZE = 0x04, + RECORD_TYPE_WKT_TYPE = 0x05, + RECORD_TYPE_WKT_ACTION = 0x06, + RECORD_TYPE_WKT_HANDOVER_REQUEST = 0x07, + RECORD_TYPE_WKT_HANDOVER_SELECT = 0x08, + RECORD_TYPE_WKT_HANDOVER_CARRIER = 0x09, + RECORD_TYPE_WKT_ALTERNATIVE_CARRIER = 0x0a, + RECORD_TYPE_WKT_COLLISION_RESOLUTION = 0x0b, + RECORD_TYPE_WKT_ERROR = 0x0c, + RECORD_TYPE_MIME_TYPE = 0x0d, + RECORD_TYPE_EXT_AAR = 0x0e, + RECORD_TYPE_EMPTY = 0xfd, + RECORD_TYPE_UNKNOWN = 0xfe, + RECORD_TYPE_ERROR = 0xff +}; + +#define RECORD_TYPE_WKT "urn:nfc:wkt:" +#define RECORD_TYPE_EXTERNAL "urn:nfc:ext:" +#define AAR_STRING "android.com:pkg" + +struct near_ndef_record_header { + uint8_t mb; + uint8_t me; + uint8_t cf; + uint8_t sr; + uint8_t il; + uint8_t tnf; + uint8_t il_length; + uint8_t *il_field; + uint32_t payload_len; + uint32_t offset; + uint8_t type_len; + enum record_type rec_type; + char *type_name; + uint32_t header_len; +}; + +struct near_ndef_text_payload { + char *encoding; + char *language_code; + char *data; +}; + +struct near_ndef_uri_payload { + uint8_t identifier; + + uint32_t field_length; + uint8_t *field; +}; + +struct near_ndef_sp_payload { + struct near_ndef_uri_payload *uri; + + uint8_t number_of_title_records; + struct near_ndef_text_payload **title_records; + + uint32_t size; /* from Size record*/ + char *type; /* from Type record*/ + char *action; + /* TODO add icon and other records fields*/ +}; + +struct near_ndef_mime_payload { + char *type; + + struct { + enum handover_carrier carrier_type; + uint16_t properties; /* e.g.: NO_PAIRING_KEY */ + } handover; +}; + +/* Handover record definitions */ + +/* alternative record (AC) length based on cdr length without adata */ +#define AC_RECORD_PAYLOAD_LEN(cdr_len) (3 + cdr_len) + +struct near_ndef_ac_payload { + enum carrier_power_state cps; /* carrier power state */ + + uint8_t cdr_len; /* carrier data reference length */ + uint8_t *cdr; /* carrier data reference */ + uint8_t adata_refcount; /* auxiliary data reference count */ + + /* !: if adata_refcount == 0, then there's no data reference */ + uint16_t **adata; /* auxiliary data reference */ +}; + +/* Default Handover version */ +#define HANDOVER_VERSION 0x12 +#define HANDOVER_MAJOR(version) (((version) >> 4) & 0xf) +#define HANDOVER_MINOR(version) ((version) & 0xf) + + +/* General Handover Request/Select record */ +struct near_ndef_ho_payload { + uint8_t version; /* version id */ + uint16_t collision_record; /* collision record */ + + uint8_t number_of_ac_payloads; /* At least 1 ac is needed */ + struct near_ndef_ac_payload **ac_payloads; + + /* Optional records */ + uint16_t *err_record; /* not NULL if present */ + + uint8_t number_of_cfg_payloads; /* extra NDEF records */ + struct near_ndef_mime_payload **cfg_payloads; +}; + +struct near_ndef_aar_payload { + char *package; +}; + +struct near_ndef_record { + char *path; + + struct near_ndef_record_header *header; + + /* specific payloads */ + struct near_ndef_text_payload *text; + struct near_ndef_uri_payload *uri; + struct near_ndef_sp_payload *sp; + struct near_ndef_mime_payload *mime; + struct near_ndef_ho_payload *ho; /* handover payload */ + struct near_ndef_aar_payload *aar; + + char *type; + + uint8_t *data; + size_t data_len; +}; + +static DBusConnection *connection = NULL; + +static inline void fillb8(uint8_t *ptr, uint32_t len) +{ + (*(uint8_t *)(ptr)) = ((uint8_t)(len)); +} + +static inline void fillb16(uint8_t *ptr, uint32_t len) +{ + fillb8((ptr), (uint16_t)(len) >> 8); + fillb8((uint8_t *)(ptr) + 1, len); +} + +static inline void fillb32(uint8_t *ptr, uint32_t len) +{ + fillb16((ptr), (uint32_t)(len) >> 16); + fillb16((uint8_t *)(ptr) + 2, (uint32_t)(len)); +} + +char *__near_ndef_record_get_path(struct near_ndef_record *record) +{ + return record->path; +} + +char *__near_ndef_record_get_type(struct near_ndef_record *record) +{ + return record->type; +} + +uint8_t *__near_ndef_record_get_data(struct near_ndef_record *record, + size_t *len) +{ + *len = record->data_len; + + return record->data; +} + +uint8_t *__near_ndef_record_get_payload(struct near_ndef_record *record, + size_t *len) +{ + *len = record->header->payload_len; + + return record->data + record->header->header_len; +} + +void __near_ndef_append_records(DBusMessageIter *iter, GList *records) +{ + GList *list; + + DBG(""); + + for (list = records; list; list = list->next) { + struct near_ndef_record *record = list->data; + uint8_t *data; + size_t data_len; + + data = __near_ndef_record_get_data(record, &data_len); + if (!data) + continue; + + dbus_message_iter_append_fixed_array(iter, DBUS_TYPE_BYTE, + &data, data_len); + } +} + +static const char *uri_prefixes[NFC_MAX_URI_ID + 1] = { + "", + "http://www.", + "https://www.", + "http://", + "https://", + "tel:", + "mailto:", + "ftp://anonymous:anonymous@", + "ftp://ftp.", + "ftps://", + "sftp://", + "smb://", + "nfs://", + "ftp://", + "dav://", + "news:", + "telnet://", + "imap:", + "rstp://", + "urn:", + "pop:", + "sip:", + "sips:", + "tftp:", + "btspp://", + "btl2cap://", + "btgoep://", + "tcpobex://", + "irdaobex://", + "file://", + "urn:epc:id:", + "urn:epc:tag:", + "urn:epc:pat:", + "urn:epc:raw:", + "urn:epc:", + "urn:nfc:", +}; + +const char *__near_ndef_get_uri_prefix(uint8_t id) +{ + if (id > NFC_MAX_URI_ID) + return NULL; + + return uri_prefixes[id]; +} + +static gboolean property_get_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_ndef_record *record = user_data; + const char *type; + + DBG(""); + + switch (record->header->rec_type) { + case RECORD_TYPE_WKT_SIZE: + case RECORD_TYPE_WKT_TYPE: + case RECORD_TYPE_WKT_ACTION: + case RECORD_TYPE_WKT_ALTERNATIVE_CARRIER: + case RECORD_TYPE_WKT_COLLISION_RESOLUTION: + case RECORD_TYPE_WKT_ERROR: + case RECORD_TYPE_UNKNOWN: + case RECORD_TYPE_ERROR: + case RECORD_TYPE_EMPTY: + type = NULL; + break; + + case RECORD_TYPE_WKT_TEXT: + type = "Text"; + break; + + case RECORD_TYPE_WKT_URI: + type = "URI"; + break; + + case RECORD_TYPE_WKT_SMART_POSTER: + type = "SmartPoster"; + break; + + case RECORD_TYPE_WKT_HANDOVER_REQUEST: + type = "HandoverRequest"; + break; + + case RECORD_TYPE_WKT_HANDOVER_SELECT: + type = "HandoverSelect"; + break; + + case RECORD_TYPE_WKT_HANDOVER_CARRIER: + type = "HandoverCarrier"; + break; + + case RECORD_TYPE_MIME_TYPE: + type = "MIME"; + break; + + case RECORD_TYPE_EXT_AAR: + type = "AAR"; + break; + } + + if (!type) + return FALSE; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &type); + + return TRUE; +} + +static gboolean text_exists(const GDBusPropertyTable *property, void *data) +{ + struct near_ndef_record *record = data; + + DBG(""); + + if (record->text) + return TRUE; + + if (record->sp && record->sp->title_records) + return TRUE; + + DBG("No text"); + + return FALSE; +} + +static const char *get_text_payload(const GDBusPropertyTable *property, + struct near_ndef_text_payload *text) +{ + if (!strcmp(property->name, "Encoding")) + return text->encoding; + else if (!strcmp(property->name, "Language")) + return text->language_code; + else if (!strcmp(property->name, "Representation")) + return text->data; + else + return NULL; +} + +static gboolean property_get_text(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_ndef_record *record = user_data; + const char *text; + + DBG(""); + + if (record->text) { + text = get_text_payload(property, record->text); + if (!text) + return FALSE; + + DBG("text %s", text); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &text); + + return TRUE; + } + + if (record->sp && record->sp->title_records) { + int i; + + for (i = 0; i < record->sp->number_of_title_records; i++) { + text = get_text_payload(property, + record->sp->title_records[i]); + if (!text) + continue; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, + &text); + } + + return TRUE; + } + + return FALSE; +} + +static gboolean uri_exists(const GDBusPropertyTable *property, void *data) +{ + struct near_ndef_record *record = data; + + DBG(""); + + if (record->uri) + return TRUE; + + if (record->sp && record->sp->uri) + return TRUE; + + DBG("No URI"); + + return FALSE; +} + +static gboolean property_get_uri(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_ndef_record *record = user_data; + struct near_ndef_uri_payload *uri; + char *value; + const char *prefix = NULL; + + DBG(""); + + if (record->uri) + uri = record->uri; + else if (record->sp && record->sp->uri) + uri = record->sp->uri; + else + return FALSE; + + if (uri->identifier > NFC_MAX_URI_ID) { + near_error("Invalid URI identifier 0x%x", uri->identifier); + return FALSE; + } + + prefix = uri_prefixes[uri->identifier]; + + DBG("URI prefix %s", prefix); + + value = g_strdup_printf("%s%.*s", prefix, uri->field_length, + uri->field); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &value); + + g_free(value); + + return TRUE; +} + +static gboolean sp_action_exists(const GDBusPropertyTable *property, + void *data) +{ + struct near_ndef_record *record = data; + + DBG(""); + + if (record->sp && record->sp->action) + return TRUE; + + DBG("No SmartPoster action"); + + return FALSE; +} + +static gboolean sp_mime_exists(const GDBusPropertyTable *property, void *data) +{ + struct near_ndef_record *record = data; + + DBG(""); + + if (record->sp && record->sp->type) + return TRUE; + + DBG("No SmartPoster MIME type"); + + return FALSE; +} + +static gboolean sp_size_exists(const GDBusPropertyTable *property, void *data) +{ + struct near_ndef_record *record = data; + + DBG(""); + + if (record->sp && record->sp->size) + return TRUE; + + DBG("No SmartPoster size"); + + return FALSE; +} + +static gboolean property_get_action(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_ndef_record *record = user_data; + + DBG("%s", record->sp->action); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &record->sp->action); + + return TRUE; +} + +static gboolean property_get_mime_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_ndef_record *record = user_data; + + DBG("%s", record->sp->type); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &record->sp->type); + + return TRUE; +} + +static gboolean property_get_size(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_ndef_record *record = user_data; + + DBG("%d", record->sp->size); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &record->sp->size); + + return TRUE; +} + +static gboolean mime_exists(const GDBusPropertyTable *property, void *data) +{ + struct near_ndef_record *record = data; + + DBG(""); + + if (record->mime) + return TRUE; + + DBG("No MIME"); + + return FALSE; +} + +static gboolean property_get_mime(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_ndef_record *record = user_data; + + DBG(""); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &record->mime->type); + + return TRUE; +} + +static gboolean aar_exists(const GDBusPropertyTable *property, void *data) +{ + struct near_ndef_record *record = data; + + DBG(""); + + if (record->aar) + return TRUE; + + DBG("No AAR"); + + return FALSE; +} + +static gboolean property_get_aar(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_ndef_record *record = user_data; + + DBG(""); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &record->aar->package); + + return TRUE; +} + +static const GDBusPropertyTable record_properties[] = { + + { "Type", "s", property_get_type }, + { "Encoding", "s", property_get_text, NULL, text_exists }, + { "Language", "s", property_get_text, NULL, text_exists }, + { "Representation", "s", property_get_text, NULL, text_exists}, + { "URI", "s", property_get_uri, NULL, uri_exists }, + { "Action", "s", property_get_action, NULL, sp_action_exists }, + { "MIMEType", "s", property_get_mime_type, NULL, sp_mime_exists }, + { "Size", "u", property_get_size, NULL, sp_size_exists }, + { "MIME", "s", property_get_mime, NULL, mime_exists }, + { "AAR", "s", property_get_aar, NULL, aar_exists }, + { } +}; + +static void free_text_payload(struct near_ndef_text_payload *text) +{ + if (!text) + return; + + g_free(text->encoding); + g_free(text->language_code); + g_free(text->data); + g_free(text); +} + +static void free_uri_payload(struct near_ndef_uri_payload *uri) +{ + if (!uri) + return; + + g_free(uri->field); + g_free(uri); +} + +static void free_sp_payload(struct near_ndef_sp_payload *sp) +{ + uint8_t i; + + if (!sp) + return; + + free_uri_payload(sp->uri); + + if (sp->title_records) { + for (i = 0; i < sp->number_of_title_records; i++) + free_text_payload(sp->title_records[i]); + } + + g_free(sp->title_records); + g_free(sp->type); + g_free(sp->action); + g_free(sp); +} + +static void free_mime_payload(struct near_ndef_mime_payload *mime) +{ + if (!mime) + return; + + g_free(mime->type); + g_free(mime); +} + +static void free_ac_payload(struct near_ndef_ac_payload *ac) +{ + if (!ac) + return; + + g_free(ac->cdr); + g_free(ac->adata); + g_free(ac); +} + +static void free_ho_payload(struct near_ndef_ho_payload *ho) +{ + int i; + + if (!ho) + return; + + if (ho->ac_payloads) { + for (i = 0; i < ho->number_of_ac_payloads; i++) + free_ac_payload(ho->ac_payloads[i]); + } + + g_free(ho->ac_payloads); + g_free(ho); +} + +static void free_aar_payload(struct near_ndef_aar_payload *aar) +{ + if (!aar) + return; + + g_free(aar->package); + g_free(aar); +} + +static void free_ndef_record(struct near_ndef_record *record) +{ + if (!record) + return; + + g_free(record->path); + + if (record->header) { + + switch (record->header->rec_type) { + case RECORD_TYPE_WKT_SIZE: + case RECORD_TYPE_WKT_TYPE: + case RECORD_TYPE_WKT_ACTION: + case RECORD_TYPE_WKT_HANDOVER_CARRIER: + case RECORD_TYPE_WKT_ALTERNATIVE_CARRIER: + case RECORD_TYPE_WKT_COLLISION_RESOLUTION: + case RECORD_TYPE_WKT_ERROR: + case RECORD_TYPE_EMPTY: + case RECORD_TYPE_UNKNOWN: + case RECORD_TYPE_ERROR: + break; + + case RECORD_TYPE_WKT_HANDOVER_REQUEST: + case RECORD_TYPE_WKT_HANDOVER_SELECT: + free_ho_payload(record->ho); + break; + + case RECORD_TYPE_WKT_TEXT: + free_text_payload(record->text); + break; + + case RECORD_TYPE_WKT_URI: + free_uri_payload(record->uri); + break; + + case RECORD_TYPE_WKT_SMART_POSTER: + free_sp_payload(record->sp); + break; + + case RECORD_TYPE_MIME_TYPE: + free_mime_payload(record->mime); + break; + + case RECORD_TYPE_EXT_AAR: + free_aar_payload(record->aar); + break; + } + + g_free(record->header->il_field); + g_free(record->header->type_name); + } + + g_free(record->header); + g_free(record->type); + g_free(record->data); + g_free(record); +} + +static void free_ndef_message(struct near_ndef_message *msg) +{ + if (!msg) + return; + + g_free(msg->data); + g_free(msg); +} + +void __near_ndef_record_free(struct near_ndef_record *record) +{ + g_dbus_unregister_interface(connection, record->path, + NFC_RECORD_INTERFACE); + + free_ndef_record(record); +} + +static char *action_to_string(uint8_t action) +{ + switch (action) { + case RECORD_ACTION_DO: + return "Do"; + case RECORD_ACTION_SAVE: + return "Save"; + case RECORD_ACTION_EDIT: + return "Edit"; + default: + near_error("Unknown action 0x%x", action); + return NULL; + } +} + +static enum record_type get_external_record_type(uint8_t *type, + size_t type_length) +{ + DBG(""); + + if (strncmp((char *) type, BT_MIME_STRING_2_0, + sizeof(BT_MIME_STRING_2_0) - 1) == 0) + return RECORD_TYPE_MIME_TYPE; + else if (strncmp((char *) type, AAR_STRING, + sizeof(AAR_STRING) - 1) == 0) + return RECORD_TYPE_EXT_AAR; + else + return RECORD_TYPE_UNKNOWN; +} + +static enum record_type get_record_type(enum record_tnf tnf, + uint8_t *type, size_t type_length) +{ + DBG(""); + + switch (tnf) { + case RECORD_TNF_URI: + break; + + case RECORD_TNF_EMPTY: + if (type_length != 0) + return RECORD_TYPE_ERROR; + else + return RECORD_TYPE_EMPTY; + break; + + case RECORD_TNF_UNKNOWN: + if (type_length != 0) + return RECORD_TYPE_ERROR; + else + return RECORD_TYPE_UNKNOWN; + break; + + case RECORD_TNF_UNCHANGED: + if (type_length != 0) + return RECORD_TYPE_ERROR; + else + return RECORD_TNF_UNCHANGED; + break; + + case RECORD_TNF_RESERVED: + return RECORD_TYPE_ERROR; + + case RECORD_TNF_WELLKNOWN: + if (type_length == 1) { + if (type[0] == 'T') + return RECORD_TYPE_WKT_TEXT; + else if (type[0] == 'U') + return RECORD_TYPE_WKT_URI; + else if (type[0] == 's') + return RECORD_TYPE_WKT_SIZE; + else if (type[0] == 't') + return RECORD_TYPE_WKT_TYPE; + else + return RECORD_TYPE_UNKNOWN; + + } else if (type_length == 2) { + if (strncmp((char *)type, "Sp", 2) == 0) + return RECORD_TYPE_WKT_SMART_POSTER; + else if (strncmp((char *) type, "Hr", 2) == 0) + return RECORD_TYPE_WKT_HANDOVER_REQUEST; + else if (strncmp((char *) type, "Hs", 2) == 0) + return RECORD_TYPE_WKT_HANDOVER_SELECT; + else if (strncmp((char *) type, "Hc", 2) == 0) + return RECORD_TYPE_WKT_HANDOVER_CARRIER; + else if (strncmp((char *) type, "ac", 2) == 0) + return RECORD_TYPE_WKT_ALTERNATIVE_CARRIER; + else if (strncmp((char *) type, "cr", 2) == 0) + return RECORD_TYPE_WKT_COLLISION_RESOLUTION; + else + return RECORD_TYPE_UNKNOWN; + + } else if (type_length == 3) { + if (strncmp((char *)type, "act", 3) == 0) + return RECORD_TYPE_WKT_ACTION; + else if (strncmp((char *)type, "err", 3) == 0) + return RECORD_TYPE_WKT_ERROR; + else + return RECORD_TYPE_UNKNOWN; + + } + + case RECORD_TNF_MIME: + return RECORD_TYPE_MIME_TYPE; + + case RECORD_TNF_EXTERNAL: + return get_external_record_type(type, type_length); + + } + + return RECORD_TYPE_UNKNOWN; +} + +static int build_record_type_string(struct near_ndef_record *rec) +{ + uint8_t tnf; + + DBG(""); + + if (!rec || !rec->header) + return -EINVAL; + + tnf = rec->header->tnf; + + if (rec->header->rec_type == RECORD_TYPE_WKT_SMART_POSTER) { + rec->type = g_strdup_printf(RECORD_TYPE_WKT "U"); + return 0; + } + + switch (tnf) { + case RECORD_TNF_EMPTY: + case RECORD_TNF_UNKNOWN: + case RECORD_TNF_UNCHANGED: + case RECORD_TNF_RESERVED: + return -EINVAL; + + case RECORD_TNF_URI: + case RECORD_TNF_MIME: + rec->type = g_strndup(rec->header->type_name, + rec->header->type_len); + break; + + case RECORD_TNF_WELLKNOWN: + rec->type = g_strdup_printf(RECORD_TYPE_WKT "%s", + rec->header->type_name); + break; + + case RECORD_TNF_EXTERNAL: + rec->type = g_strdup_printf(RECORD_TYPE_EXTERNAL "%s", + rec->header->type_name); + break; + } + + return 0; +} + +static uint8_t validate_record_begin_and_end_bits(uint8_t *msg_mb, + uint8_t *msg_me, uint8_t rec_mb, + uint8_t rec_me) +{ + DBG(""); + + if (!msg_mb || !msg_me) + return 0; + + /* Validating record header begin and end bits + * eg: Single record: [mb:1,me:1] + * Two records: [mb:1,me:0 - mb:0,me:1] + * Three or more records [mb:1,me:0 - mb:0,me:0 .. mb:0,me:1] + **/ + + if (rec_mb == 1) { + if (*msg_mb != 1) + *msg_mb = rec_mb; + else + return -EINVAL; + + } + + if (rec_me == 1) { + if (*msg_me != 1) { + if (*msg_mb == 1) + *msg_me = rec_me; + else + return -EINVAL; + + } else + return -EINVAL; + + } + + return 0; +} + +/* + * Parse the ndef record header and cache the begin, end, chunkflag, + * short-record and type-name-format bits. ID length and field, record + * type, payload length and offset (where payload byte starts in input + * parameter). Validate offset for every step forward against total + * available length. + */ +static struct near_ndef_record_header *parse_record_header(uint8_t *rec, + uint32_t offset, uint32_t length) +{ + struct near_ndef_record_header *rec_header = NULL; + uint8_t *type = NULL; + uint32_t header_len = 0; + + DBG("length %d", length); + + if (!rec || offset >= length) + return NULL; + + /* This check is for empty record. */ + if ((length - offset) < NDEF_MSG_MIN_LENGTH) + return NULL; + + rec_header = g_try_malloc0(sizeof(struct near_ndef_record_header)); + if (!rec_header) + return NULL; + + rec_header->mb = RECORD_MB_BIT(rec[offset]); + rec_header->me = RECORD_ME_BIT(rec[offset]); + rec_header->sr = RECORD_SR_BIT(rec[offset]); + rec_header->il = RECORD_IL_BIT(rec[offset]); + rec_header->tnf = RECORD_TNF_BIT(rec[offset]); + + DBG("mb %d me %d sr %d il %d tnf %d", + rec_header->mb, rec_header->me, rec_header->sr, + rec_header->il, rec_header->tnf); + + offset++; + rec_header->type_len = rec[offset++]; + header_len = 2; /* type length + header bits */ + + if (rec_header->sr == 1) { + rec_header->payload_len = rec[offset++]; + header_len++; + } else { + rec_header->payload_len = near_get_be32(rec + offset); + offset += 4; + header_len += 4; + + if ((offset + rec_header->payload_len) > length) + goto fail; + } + + DBG("payload length %d", rec_header->payload_len); + + if (rec_header->il == 1) { + rec_header->il_length = rec[offset++]; + header_len++; + + if ((offset + rec_header->payload_len) > length) + goto fail; + } + + if (rec_header->type_len > 0) { + if ((offset + rec_header->type_len) > length) + goto fail; + + type = g_try_malloc0(rec_header->type_len); + if (!type) + goto fail; + + memcpy(type, rec + offset, rec_header->type_len); + offset += rec_header->type_len; + header_len += rec_header->type_len; + + if ((offset + rec_header->payload_len) > length) + goto fail; + } + + if (rec_header->il_length > 0) { + if ((offset + rec_header->il_length) > length) + goto fail; + + rec_header->il_field = g_try_malloc0(rec_header->il_length); + if (!rec_header->il_field) + goto fail; + + memcpy(rec_header->il_field, rec + offset, + rec_header->il_length); + offset += rec_header->il_length; + header_len += rec_header->il_length; + + if ((offset + rec_header->payload_len) > length) + goto fail; + } + + rec_header->rec_type = get_record_type(rec_header->tnf, type, + rec_header->type_len); + rec_header->offset = offset; + + rec_header->header_len = header_len; + rec_header->type_name = g_strndup((char *) type, rec_header->type_len); + + /* Check that NDEF record is not corrupted */ + if (length != (rec_header->header_len + rec_header->payload_len)) + rec_header->rec_type = RECORD_TYPE_ERROR; + + g_free(type); + + return rec_header; + +fail: + near_error("parsing record header failed"); + + g_free(type); + g_free(rec_header->il_field); + g_free(rec_header->type_name); + g_free(rec_header); + + return NULL; +} + +static struct near_ndef_text_payload * +parse_text_payload(uint8_t *payload, uint32_t length) +{ + struct near_ndef_text_payload *text_payload = NULL; + uint8_t status, lang_length; + uint32_t offset; + + DBG(""); + + if (!payload) + return NULL; + + offset = 0; + text_payload = g_try_malloc0(sizeof(struct near_ndef_text_payload)); + if (!text_payload) + return NULL; + + /* 0x80 is used to get 7th bit value (0th bit is LSB) */ + status = ((payload[offset] & 0x80) >> 7); + + text_payload->encoding = (status == 0) ? + g_strdup("UTF-8") : g_strdup("UTF-16"); + + /* 0x3F is used to get 5th-0th bits value (0th bit is LSB) */ + lang_length = (payload[offset] & 0x3F); + offset++; + + if (lang_length > 0) { + if ((offset + lang_length) >= length) + goto fail; + + text_payload->language_code = g_strndup( + (char *)(payload + offset), + lang_length); + } else { + text_payload->language_code = NULL; + } + + offset += lang_length; + + if ((length - lang_length - 1) > 0) { + text_payload->data = g_strndup((char *)(payload + offset), + length - lang_length - 1); + } else { + text_payload->data = NULL; + } + + if (offset >= length) + goto fail; + + DBG("Encoding '%s'", text_payload->encoding); + DBG("Language Code '%s'", text_payload->language_code); + DBG("Data '%s'", text_payload->data); + + return text_payload; + +fail: + near_error("text payload parsing failed"); + free_text_payload(text_payload); + + return NULL; +} + +static struct near_ndef_uri_payload * +parse_uri_payload(uint8_t *payload, uint32_t length) +{ + struct near_ndef_uri_payload *uri_payload = NULL; + uint32_t index, offset; + + DBG(""); + + if (!payload) + return NULL; + + offset = 0; + uri_payload = g_try_malloc0(sizeof(struct near_ndef_uri_payload)); + if (!uri_payload) + return NULL; + + uri_payload->identifier = payload[offset]; + offset++; + if (uri_payload->identifier > NFC_MAX_URI_ID) { + near_error("Invalid URI identifier '0x%X'", + uri_payload->identifier); + goto fail; + } + + uri_payload->field_length = length - 1; + + if (uri_payload->field_length > 0) { + uri_payload->field = g_try_malloc0(uri_payload->field_length); + if (!uri_payload->field) + goto fail; + + memcpy(uri_payload->field, payload + offset, + uri_payload->field_length); + + for (index = 0; index < uri_payload->field_length; index++) { + /* URI Record Type Definition 1.0 [3.2.3] + * Any character value within the URI between + * (and including) 0 and 31 SHALL be recorded as + * an error, and the URI record to be discarded */ + if (uri_payload->field[index] <= 31) + goto fail; + } + + } + + DBG("Identifier '0X%X'", uri_payload->identifier); + DBG("Field '%.*s'", uri_payload->field_length, uri_payload->field); + + return uri_payload; + +fail: + near_error("uri payload parsing failed"); + free_uri_payload(uri_payload); + + return NULL; +} + +/* + * Validate titles records language code in Smartposter. + * There must not be two or more records with the same language identifier. + */ +static int8_t validate_language_code_in_sp_record(GSList *titles) +{ + uint8_t i, j, length; + struct near_ndef_text_payload *title1, *title2; + + DBG(""); + + if (!titles) + return -EINVAL; + + length = g_slist_length(titles); + + for (i = 0; i < length; i++) { + title1 = g_slist_nth_data(titles, i); + + for (j = i + 1; j < length; j++) { + title2 = g_slist_nth_data(titles, j); + + if ((!title1->language_code) && + (!title2->language_code)) + continue; + + if (g_strcmp0(title1->language_code, + title2->language_code) == 0) + return -EINVAL; + } + } + + return 0; +} + +static struct near_ndef_sp_payload * +parse_sp_payload(uint8_t *payload, uint32_t length) +{ + struct near_ndef_sp_payload *sp_payload = NULL; + struct near_ndef_record_header *rec_header = NULL; + uint8_t mb = 0, me = 0, i; + uint32_t offset; + GSList *titles = NULL, *temp; + + DBG(""); + + if (!payload) + return NULL; + + offset = 0; + sp_payload = g_try_malloc0(sizeof(struct near_ndef_sp_payload)); + if (!sp_payload) + return NULL; + + while (offset < length) { + + DBG("Record header : 0x%x", payload[offset]); + + rec_header = parse_record_header(payload, offset, length); + if (!rec_header) + goto fail; + + if (validate_record_begin_and_end_bits(&mb, &me, + rec_header->mb, rec_header->me) != 0) { + DBG("validate mb me failed"); + goto fail; + } + + offset = rec_header->offset; + + switch (rec_header->rec_type) { + case RECORD_TYPE_WKT_SMART_POSTER: + case RECORD_TYPE_WKT_HANDOVER_REQUEST: + case RECORD_TYPE_WKT_HANDOVER_SELECT: + case RECORD_TYPE_WKT_HANDOVER_CARRIER: + case RECORD_TYPE_WKT_ALTERNATIVE_CARRIER: + case RECORD_TYPE_WKT_COLLISION_RESOLUTION: + case RECORD_TYPE_MIME_TYPE: + case RECORD_TYPE_WKT_ERROR: + case RECORD_TYPE_EXT_AAR: + case RECORD_TYPE_UNKNOWN: + break; + + case RECORD_TYPE_EMPTY: + case RECORD_TYPE_ERROR: + goto fail; + + case RECORD_TYPE_WKT_URI: + /* URI record should be only one. */ + if (sp_payload->uri) + goto fail; + + sp_payload->uri = parse_uri_payload(payload + offset, + rec_header->payload_len); + if (!sp_payload->uri) + goto fail; + + break; + + case RECORD_TYPE_WKT_TEXT: + /* + * Title records can zero or more. First fill the + * records in list and validate language identifier + * and then cache them into sp record structure. + */ + { + struct near_ndef_text_payload *title; + title = parse_text_payload(payload + offset, + rec_header->payload_len); + if (!title) + goto fail; + + titles = g_slist_append(titles, title); + } + break; + + case RECORD_TYPE_WKT_SIZE: + /* + * If payload length is not exactly 4 bytes + * then record is wrong. + */ + if (rec_header->payload_len != 4) + goto fail; + + sp_payload->size = near_get_be32(payload + offset); + break; + + case RECORD_TYPE_WKT_TYPE: + + if (rec_header->payload_len > 0) { + sp_payload->type = g_try_malloc0( + rec_header->payload_len); + if (!sp_payload->type) + goto fail; + + sp_payload->type = g_strndup( + (char *) payload + offset, + rec_header->payload_len); + } + + break; + + case RECORD_TYPE_WKT_ACTION: + /* + * If the action record exists, payload should be + * single byte, otherwise consider it as error. + */ + if (rec_header->payload_len != 1) + goto fail; + + sp_payload->action = + g_strdup(action_to_string(payload[offset])); + + break; + } + + offset += rec_header->payload_len; + g_free(rec_header->il_field); + g_free(rec_header->type_name); + g_free(rec_header); + rec_header = NULL; + } + + /* + * Code to fill smart poster record structure from + * 'titles' list. + */ + if (!titles) + return sp_payload; + + if (validate_language_code_in_sp_record(titles) != 0) { + DBG("language code validation failed"); + goto fail; + } + + temp = titles; + sp_payload->number_of_title_records = g_slist_length(temp); + sp_payload->title_records = g_try_malloc0( + sp_payload->number_of_title_records * + sizeof(struct near_ndef_text_payload *)); + if (!sp_payload->title_records) + goto fail; + + for (i = 0; i < sp_payload->number_of_title_records; i++) { + sp_payload->title_records[i] = temp->data; + temp = temp->next; + } + + g_slist_free(titles); + titles = NULL; + + return sp_payload; + +fail: + near_error("smart poster payload parsing failed"); + + if (rec_header) { + g_free(rec_header->type_name); + g_free(rec_header->il_field); + g_free(rec_header); + } + + free_sp_payload(sp_payload); + g_slist_free(titles); + + return NULL; +} + +static void correct_eir_len(struct carrier_data *data) +{ + /* + * Android 4.1 BUG - OOB EIR length should be in LE, but is in BE. + * Fortunately payload length is 1 byte so this can be detected and + * corrected before sending it to handover agent. + */ + if (data->data[0] == 0) { + DBG("EIR length in BE"); + data->data[0] = data->data[1]; + data->data[1] = 0; + } + + /* + * Some Nokia BH-505 report total OOB block length without length field + * size. + */ + if (data->data[0] == data->size - 2) { + DBG("EIR length without length field size"); + data->data[0] += 2; + } +} + +static int process_mime_type(struct near_ndef_mime_payload *mime, + struct carrier_data *c_data) +{ + int err = -EINVAL; + + DBG(""); + + if (!mime || !c_data) + return -EINVAL; + + switch (mime->handover.carrier_type) { + case NEAR_CARRIER_BLUETOOTH: + err = __near_agent_handover_push_data(HO_AGENT_BT, c_data); + if (err == -ESRCH) + err = __near_bluetooth_parse_oob_record(c_data, + &mime->handover.properties, true); + break; + + case NEAR_CARRIER_WIFI: + err = __near_agent_handover_push_data(HO_AGENT_WIFI, c_data); + break; + + case NEAR_CARRIER_EMPTY: + case NEAR_CARRIER_UNKNOWN: + break; + } + + return err; +} + +static struct near_ndef_mime_payload *parse_mime_type( + struct near_ndef_record *record, uint8_t *ndef_data, + size_t ndef_length, size_t offset, + uint32_t payload_length, struct carrier_data **c_data) +{ + struct near_ndef_mime_payload *mime; + struct carrier_data *c_temp; + + DBG(""); + + if (!c_data || !ndef_data || + ((offset + payload_length) > ndef_length)) + return NULL; + + mime = g_try_malloc0(sizeof(struct near_ndef_mime_payload)); + if (!mime) + return NULL; + + c_temp = g_try_malloc0(sizeof(struct carrier_data)); + if (!c_temp) { + g_free(mime); + return NULL; + } + + mime->type = g_strdup(record->header->type_name); + + DBG("MIME Type '%s'", mime->type); + if (strcmp(mime->type, BT_MIME_STRING_2_1) == 0) { + mime->handover.carrier_type = NEAR_CARRIER_BLUETOOTH; + c_temp->type = BT_MIME_V2_1; + c_temp->size = record->header->payload_len; + memcpy(c_temp->data, ndef_data + offset, c_temp->size); + correct_eir_len(c_temp); + } else if (strcmp(mime->type, BT_MIME_STRING_2_0) == 0) { + mime->handover.carrier_type = NEAR_CARRIER_BLUETOOTH; + c_temp->type = BT_MIME_V2_0; + c_temp->size = record->header->payload_len; + memcpy(c_temp->data, ndef_data + offset, c_temp->size); + } else if (strcmp(mime->type, WIFI_WSC_MIME_STRING) == 0) { + mime->handover.carrier_type = NEAR_CARRIER_WIFI; + c_temp->type = WIFI_WSC_MIME; + c_temp->size = record->header->payload_len; + memcpy(c_temp->data, ndef_data + offset, c_temp->size); + } else { + g_free(c_temp); + c_temp = NULL; + *c_data = NULL; + return mime; + } + + *c_data = c_temp; + + return mime; +} + +/* Set the MB bit in message header */ +static uint8_t near_ndef_set_mb(uint8_t *hdr, bool first_rec) +{ + /* Reset bits 0x40 */ + *hdr &= (0xFF & (~RECORD_MB)); + + /* Set if needed */ + if (first_rec) + *hdr |= RECORD_MB; + + return *hdr; +} + +/* Set the MB/ME bit in message header */ +static uint8_t near_ndef_set_me(uint8_t *hdr, bool last_rec) +{ + /* Reset bits 0x80 */ + *hdr &= (0xFF & (~RECORD_ME)); + + /* Set if needed */ + if (last_rec) + *hdr |= RECORD_ME; + + return *hdr; +} + +/* Set the MB/ME bit in message header */ +static uint8_t near_ndef_set_mb_me(uint8_t *hdr, bool first_rec, + bool last_rec) +{ + near_ndef_set_mb(hdr, first_rec); + return near_ndef_set_me(hdr, last_rec); +} + +/* Caller should put own payload starting from offset value */ +static struct near_ndef_message *ndef_message_alloc_complete(char *type_name, + uint32_t payload_len, + char *payload_id, + uint8_t payload_id_len, + enum record_tnf tnf, + bool first_rec, + bool last_rec) +{ + struct near_ndef_message *msg; + uint8_t hdr = 0, type_len, sr_bit, il_bit, id_len; + + msg = g_try_malloc0(sizeof(struct near_ndef_message)); + if (!msg) + return NULL; + + msg->length = 0; + msg->offset = 0; + msg->length++; /* record header*/ + msg->length++; /* type name length byte*/ + + type_len = (type_name) ? strlen(type_name) : 0; + id_len = (payload_id) ? payload_id_len : 0; + sr_bit = (payload_len <= NDEF_MSG_SHORT_RECORD_MAX_LENGTH) + ? TRUE : FALSE; + + il_bit = (payload_id) ? TRUE : FALSE; + + msg->length += (sr_bit) ? 1 : 4; + msg->length += (il_bit) ? 1 : 0; + msg->length += type_len; + msg->length += payload_len; + msg->length += id_len; + + msg->data = g_try_malloc0(msg->length); + if (!msg->data) + goto fail; + + /* Set MB ME bits */ + hdr = near_ndef_set_mb_me(&hdr, first_rec, last_rec); + + if (sr_bit) + hdr |= RECORD_SR; + + hdr = RECORD_TNF_WKT_SET(hdr); + if (il_bit) + hdr |= RECORD_IL; + + switch (tnf) { + case RECORD_TNF_EMPTY: + hdr = RECORD_TNF_EMPTY_SET(hdr); + break; + + case RECORD_TNF_URI: + hdr = RECORD_TNF_URI_SET(hdr); + break; + + case RECORD_TNF_EXTERNAL: + hdr = RECORD_TNF_EXTERNAL_SET(hdr); + break; + case RECORD_TNF_UNKNOWN: + hdr = RECORD_TNF_UKNOWN_SET(hdr); + break; + + case RECORD_TNF_UNCHANGED: + hdr = RECORD_TNF_UNCHANGED_SET(hdr); + break; + + case RECORD_TNF_WELLKNOWN: + hdr = RECORD_TNF_WKT_SET(hdr); + break; + + case RECORD_TNF_MIME: + hdr = RECORD_TNF_MIME_SET(hdr); + break; + + case RECORD_TNF_RESERVED: + goto fail; + } + + msg->data[msg->offset++] = hdr; + msg->data[msg->offset++] = type_len; + + if (sr_bit) { + msg->data[msg->offset++] = payload_len; + } else { + fillb32((msg->data + msg->offset), payload_len); + msg->offset += 4; + } + + if (il_bit) + msg->data[msg->offset++] = payload_id_len; + + if (type_name) { + memcpy(msg->data + msg->offset, type_name, type_len); + msg->offset += type_len; + } + + if (il_bit) { + memcpy(msg->data + msg->offset, payload_id, payload_id_len); + msg->offset += payload_id_len; + } + + return msg; + +fail: + near_error("ndef message struct allocation failed"); + free_ndef_message(msg); + + return NULL; +} + +/* + * This is a wrapper to ndef_message_alloc, as, in most cases, + * there's no payload id, and MB=TRUE and ME=TRUE. Default type name format + * is also set to RECORD_TNF_WELLKNOWN + * + */ +static struct near_ndef_message *ndef_message_alloc(char *type_name, + uint32_t payload_len) +{ + return ndef_message_alloc_complete(type_name, payload_len, + NULL, 0, + RECORD_TNF_WELLKNOWN, + true, true); +} + +static enum carrier_power_state get_cps(uint8_t data) +{ + /* enum carrier_power_state values match binary format */ + return data & AC_CPS_MASK; +} + +static struct near_ndef_ac_payload *parse_ac_payload(uint8_t *payload, + uint32_t length) +{ + struct near_ndef_ac_payload *ac_payload = NULL; + uint32_t offset; + + DBG(""); + + if (!payload) + return NULL; + + offset = 0; + ac_payload = g_try_malloc0(sizeof(struct near_ndef_ac_payload)); + if (!ac_payload) + goto fail; + + /* Carrier flag */ + ac_payload->cps = get_cps(payload[offset]); + offset++; + + /* Carrier data reference length */ + ac_payload->cdr_len = payload[offset]; + offset++; + + if (ac_payload->cdr_len == 0) + goto fail; + + /* Carrier data reference */ + ac_payload->cdr = g_try_malloc0(ac_payload->cdr_len + 1); + if (!ac_payload->cdr) + goto fail; + + memcpy(ac_payload->cdr, payload + offset, ac_payload->cdr_len); + offset = offset + ac_payload->cdr_len; + + /* Auxiliary data reference count */ + ac_payload->adata_refcount = payload[offset]; + offset++; + + if (ac_payload->adata_refcount == 0) + return ac_payload; + + /* save the auxiliary data reference */ + ac_payload->adata = g_try_malloc0( + ac_payload->adata_refcount * sizeof(uint16_t)); + if (!ac_payload->adata) + goto fail; + + memcpy(ac_payload->adata, payload + offset, + ac_payload->adata_refcount * sizeof(uint16_t)); + + /* and leave */ + return ac_payload; + +fail: + near_error("ac payload parsing failed"); + free_ac_payload(ac_payload); + + return NULL; +} + +/* carrier power state & carrier reference */ +static struct near_ndef_message *near_ndef_prepare_ac_message(uint8_t cps, + char *cdr, + uint8_t cdr_len) +{ + struct near_ndef_message *ac_msg; + + /* alloc "ac" message minus adata*/ + ac_msg = ndef_message_alloc_complete("ac", + AC_RECORD_PAYLOAD_LEN(cdr_len), + NULL, 0, + RECORD_TNF_WELLKNOWN, + true, true); + if (!ac_msg) + return NULL; + + /* Prepare ac message */ + ac_msg->data[ac_msg->offset++] = cps; + + ac_msg->data[ac_msg->offset++] = cdr_len; + memcpy(ac_msg->data + ac_msg->offset, cdr, cdr_len); /* cdr */ + ac_msg->offset += cdr_len; + + ac_msg->data[ac_msg->offset] = 0; /* adata ref count */ + + /* Check if we want an empty record */ + if (*cdr == 0x00) + ac_msg->length = 0; + + return ac_msg; +} + +/* Collision Record message */ +static struct near_ndef_message *near_ndef_prepare_cr_message(uint16_t cr_id) +{ + struct near_ndef_message *cr_msg; + + cr_msg = ndef_message_alloc_complete("cr", sizeof(uint16_t), + NULL, 0, + RECORD_TNF_WELLKNOWN, + true, true); + if (!cr_msg) + return NULL; + + /* Prepare ac message */ + near_put_be16(cr_id, cr_msg->data + cr_msg->offset); + + return cr_msg; +} + +static struct near_ndef_message *near_ndef_prepare_cfg_message(char *mime_type, + uint8_t *data, int data_len, + char *cdr, uint8_t cdr_len) +{ + struct near_ndef_message *msg = NULL; + + DBG(" %s", mime_type); + + if (!mime_type) + return NULL; + + msg = ndef_message_alloc_complete(mime_type, data_len, cdr, cdr_len, + RECORD_TNF_MIME, true, true); + if (!msg) + return NULL; + + /* store data */ + if (data) + memcpy(msg->data + msg->offset, data, data_len); + + return msg; +} + +/* + * Prepare alternative carrier and configuration records + * (e.g. bluetooth or wifi or Hc) + */ +static int near_ndef_prepare_ac_and_cfg_records(enum record_type type, + enum handover_carrier carrier, + struct near_ndef_message **ac, + struct near_ndef_message **cfg, + struct near_ndef_mime_payload *mime, + struct carrier_data *remote_carrier) +{ + struct carrier_data *local_carrier; + char cdr; + char *mime_type, *carrier_string; + uint16_t prop; + + DBG(""); + + if (!ac || !cfg) + return -EINVAL; + + switch (carrier) { + case NEAR_CARRIER_BLUETOOTH: + cdr = '0'; + carrier_string = "Bluetooth"; + mime_type = BT_MIME_STRING_2_1; + local_carrier = __near_agent_handover_request_data( + HO_AGENT_BT, remote_carrier); + if (local_carrier) + break; + + prop = (mime) ? mime->handover.properties : + OOB_PROPS_EMPTY; + local_carrier = __near_bluetooth_local_get_properties(prop); + + break; + + case NEAR_CARRIER_WIFI: + cdr = '1'; + carrier_string = "WiFi-WSC"; + mime_type = WIFI_WSC_MIME_STRING; + local_carrier = __near_agent_handover_request_data( + HO_AGENT_WIFI, remote_carrier); + break; + + case NEAR_CARRIER_EMPTY: + case NEAR_CARRIER_UNKNOWN: + default: + return -EINVAL; + } + + /* + * WiFi has to be handled a bit differently when we're trying + * to send the first Hr or Hs (i.e. remote_carrier == NULL). + * There are 2 invalid combinations: + * a) AP mode and sending an Hr, as we won't be able to + * initiate the association. + * b) STA mode and sending an Hs, as the AP won't be able + * initiate the association. + * + * a) is detected when local_carrier != NULL and record_type is + * Handover Request. + * b) is detected when local_carrier == NULL and record_type is + * Handover Select. + * In those 2 cases we return an error. + */ + if (carrier == NEAR_CARRIER_WIFI && !remote_carrier) { + if (local_carrier && + type == RECORD_TYPE_WKT_HANDOVER_REQUEST) { + g_free(local_carrier); + return -EINVAL; + } + + if (!local_carrier && + type == RECORD_TYPE_WKT_HANDOVER_SELECT) + return -EINVAL; + + if (!local_carrier && + type == RECORD_TYPE_WKT_HANDOVER_REQUEST) { + *cfg = near_ndef_prepare_cfg_message(mime_type, + NULL, 0, + &cdr, sizeof(cdr)); + *ac = near_ndef_prepare_ac_message(CPS_UNKNOWN, &cdr, + sizeof(cdr)); + + return 0; + } + } + + if (!local_carrier) { + DBG("Unable to retrieve local carrier %s data", carrier_string); + return -ESRCH; + } + + *cfg = near_ndef_prepare_cfg_message(mime_type, local_carrier->data, + local_carrier->size, + &cdr, sizeof(cdr)); + *ac = near_ndef_prepare_ac_message(local_carrier->state, + &cdr, sizeof(cdr)); + + g_free(local_carrier); + + if (!*cfg || !*ac) { + free_ndef_message(*ac); + free_ndef_message(*cfg); + + return -ENOMEM; + } + + return 0; +} + +static void free_ndef_list(gpointer data) +{ + struct near_ndef_message *msg = data; + + free_ndef_message(msg); +} + +static struct near_ndef_message *prepare_handover_message_header(char *type, + uint32_t msg_len, uint32_t payload_len) +{ + struct near_ndef_message *ho_msg; + + ho_msg = ndef_message_alloc(type, msg_len); + if (!ho_msg) + return NULL; + + /* + * The handover payload length is not the *real* length. + * The PL refers to the NDEF record, not the extra ones. + * So, we have to fix the payload length in the header. + */ + ho_msg->data[NDEF_PAYLOAD_LENGTH_OFFSET] = payload_len; + near_ndef_set_mb_me(ho_msg->data, true, false); + + /* Add version */ + ho_msg->data[ho_msg->offset++] = HANDOVER_VERSION; + + return ho_msg; +} + +static uint32_t ndef_message_list_length(GList *list) +{ + struct near_ndef_message *msg; + uint32_t length = 0; + + if (!list) + return 0; + + while (list) { + msg = list->data; + length += msg->length; + list = list->next; + } + + return length; +} + +static void copy_ac_records(struct near_ndef_message *ho, GList *acs) +{ + GList *temp = acs; + struct near_ndef_message *ac; + + if (!ho || !temp) + return; + + while (temp) { + ac = temp->data; + memcpy(ho->data + ho->offset, ac->data, ac->length); + /* + * AC records are part of handover message payload, + * so modifying offset. + */ + ho->offset += ac->length; + temp = temp->next; + } +} + +static void copy_cfg_records(struct near_ndef_message *ho, GList *cfgs) +{ + GList *temp = cfgs; + struct near_ndef_message *cfg; + uint32_t offset; + + if (!ho || !temp) + return; + + offset = ho->offset; + + while (temp) { + cfg = temp->data; + memcpy(ho->data + offset, cfg->data, cfg->length); + /* + * Configuration records (e.g. bt or wifi) records are not part + * of handover payload, they are consecutive ndef msgs. So + * here we are not modifying ho->offset. + */ + offset += cfg->length; + temp = temp->next; + } +} + +static void set_mb_me_to_false(gpointer data, gpointer user_data) +{ + struct near_ndef_message *msg = data; + + near_ndef_set_mb_me(msg->data, false, false); +} + +static struct near_ndef_message *near_ndef_prepare_empty_hs_message(void) +{ + struct near_ndef_message *hs_msg; + struct near_ndef_message *ac_msg; + char cdr = 0x00; + uint32_t hs_length; + + DBG(""); + + ac_msg = near_ndef_prepare_ac_message(CPS_UNKNOWN, &cdr, sizeof(cdr)); + if (!ac_msg) + return NULL; + + hs_length = 1; + hs_length += ac_msg->length; + + hs_msg = prepare_handover_message_header("Hs", hs_length, hs_length); + if (!hs_msg) + goto fail; + + near_ndef_set_mb_me(hs_msg->data, true, true); + memcpy(hs_msg->data + hs_msg->offset, ac_msg->data, ac_msg->length); + hs_msg->offset += ac_msg->length; + + if (hs_msg->offset > hs_msg->length) + goto fail; + + free_ndef_message(ac_msg); + + return hs_msg; + +fail: + free_ndef_message(ac_msg); + free_ndef_message(hs_msg); + + return NULL; +} + +static struct near_ndef_message *near_ndef_prepare_hs_reply( + GSList *remote_mimes, + GSList *remote_cfgs) +{ + struct near_ndef_message *hs_msg = NULL; + struct near_ndef_message *ac_msg; + struct near_ndef_message *cfg_msg; + struct near_ndef_mime_payload *remote_mime; + struct carrier_data *remote_cfg; + GList *ac_msgs = NULL, *cfg_msgs = NULL, *temp; + GSList *mime_iter, *cfg_iter; + uint8_t hs_length, hs_pl_length, num_of_carriers; + int ret = -EINVAL; + + DBG(""); + + /* + * Preparing empty Hs message in case remote devices has zero + * alternative carries or unknown mime types or unknown + * configuration data. + */ + if ((!remote_mimes || !remote_cfgs)) + return near_ndef_prepare_empty_hs_message(); + + mime_iter = remote_mimes; + cfg_iter = remote_cfgs; + + while (mime_iter) { + remote_mime = mime_iter->data; + remote_cfg = cfg_iter->data; + if (!remote_mime || !remote_cfg) + goto fail; + + ret = near_ndef_prepare_ac_and_cfg_records( + RECORD_TYPE_WKT_HANDOVER_SELECT, + remote_mime->handover.carrier_type, + &ac_msg, &cfg_msg, + remote_mime, remote_cfg); + if (ret == 0) { + ac_msgs = g_list_append(ac_msgs, ac_msg); + cfg_msgs = g_list_append(cfg_msgs, cfg_msg); + } + + mime_iter = mime_iter->next; + cfg_iter = cfg_iter->next; + } + + if (g_list_length(ac_msgs) == 0) { + DBG("no alternative carriers, so preparing empty Hs message"); + return near_ndef_prepare_empty_hs_message(); + } + + /* Prepare Hs message */ + hs_pl_length = 1; + /* Alternative carriers are part of handover record payload length */ + hs_pl_length += ndef_message_list_length(ac_msgs); + + hs_length = hs_pl_length; + /* Configuration records are part of handover message length */ + hs_length += ndef_message_list_length(cfg_msgs); + + hs_msg = prepare_handover_message_header("Hs", hs_length, hs_pl_length); + if (!hs_msg) + goto fail; + + num_of_carriers = g_list_length(ac_msgs); + + if (num_of_carriers == 1) { + /* only one message */ + ac_msg = ac_msgs->data; + near_ndef_set_mb_me(ac_msg->data, true, true); + } else if (num_of_carriers > 1) { + g_list_foreach(ac_msgs, set_mb_me_to_false, NULL); + /* first message */ + temp = g_list_first(ac_msgs); + ac_msg = temp->data; + near_ndef_set_mb_me(ac_msg->data, true, false); + /* last message */ + temp = g_list_last(ac_msgs); + ac_msg = temp->data; + near_ndef_set_mb_me(ac_msg->data, false, true); + } + + g_list_foreach(cfg_msgs, set_mb_me_to_false, NULL); + temp = g_list_last(cfg_msgs); + cfg_msg = temp->data; + near_ndef_set_mb_me(cfg_msg->data, false, true); + + /* copy acs */ + copy_ac_records(hs_msg, ac_msgs); + if (hs_msg->offset > hs_msg->length) + goto fail; + + /* + * copy cfgs, cfg (associated to the ac) records length + * (bt or wifi) is not part of Hs initial size. + */ + copy_cfg_records(hs_msg, cfg_msgs); + + DBG("Hs message preparation is done"); + + g_list_free_full(ac_msgs, free_ndef_list); + g_list_free_full(cfg_msgs, free_ndef_list); + + return hs_msg; + +fail: + near_error("handover Hs message preparation failed"); + + g_list_free_full(ac_msgs, free_ndef_list); + g_list_free_full(cfg_msgs, free_ndef_list); + + free_ndef_message(hs_msg); + + return NULL; +} + +static enum handover_carrier string2carrier(char *carrier) +{ + if (strcasecmp(carrier, NEAR_HANDOVER_AGENT_BLUETOOTH) == 0) + return NEAR_CARRIER_BLUETOOTH; + + if (strcasecmp(carrier, NEAR_HANDOVER_AGENT_WIFI) == 0) + return NEAR_CARRIER_WIFI; + + return NEAR_CARRIER_UNKNOWN; +} + +static struct near_ndef_message * +near_ndef_prepare_ho_message(enum record_type type, GSList *carriers) +{ + struct near_ndef_message *ho_msg = NULL; + struct near_ndef_message *cr_msg = NULL; + struct near_ndef_message *ac_msg; + struct near_ndef_message *cfg_msg; + GList *ac_msgs = NULL, *cfg_msgs = NULL, *temp; + uint16_t collision; + uint8_t ho_length, ho_pl_length; + int ret = -EINVAL; + char *str_type; + + DBG(""); + + switch (type) { + case RECORD_TYPE_WKT_HANDOVER_REQUEST: + str_type = "Hr"; + break; + + case RECORD_TYPE_WKT_HANDOVER_SELECT: + str_type = "Hs"; + break; + + default: + return NULL; + } + + /* Hr message should have at least one carrier */ + while (carriers) { + ret = near_ndef_prepare_ac_and_cfg_records( + type, + string2carrier(carriers->data), + &ac_msg, &cfg_msg, NULL, NULL); + if (ret == 0) { + ac_msgs = g_list_append(ac_msgs, ac_msg); + cfg_msgs = g_list_append(cfg_msgs, cfg_msg); + } + + carriers = carriers->next; + } + + if (g_list_length(ac_msgs) == 0) { + DBG("no alternative carriers to prepare Hr message"); + goto fail; + } + + /* Prepare Hr message */ + ho_pl_length = 1; + + /* Prepare collision resolution record MB=1 ME=0, only for Hr */ + if (type == RECORD_TYPE_WKT_HANDOVER_REQUEST) { + collision = GUINT16_TO_BE(g_random_int_range(0, G_MAXUINT16 + 1)); + cr_msg = near_ndef_prepare_cr_message(collision); + if (!cr_msg) + goto fail; + + near_ndef_set_mb_me(cr_msg->data, true, false); + + ho_pl_length += cr_msg->length; + } + + /* Alternative carriers are part of handover record payload length */ + ho_pl_length += ndef_message_list_length(ac_msgs); + + ho_length = ho_pl_length; + /* Configuration records are part of handover message length */ + ho_length += ndef_message_list_length(cfg_msgs); + + ho_msg = prepare_handover_message_header(str_type, + ho_length, ho_pl_length); + if (!ho_msg) + goto fail; + + g_list_foreach(ac_msgs, set_mb_me_to_false, NULL); + /* last message */ + temp = g_list_last(ac_msgs); + ac_msg = temp->data; + near_ndef_set_mb_me(ac_msg->data, false, true); + + /* + * Hs record payloads do not have collision recore, the first record + * will be the first ac record. + */ + if (type == RECORD_TYPE_WKT_HANDOVER_SELECT) { + temp = g_list_first(ac_msgs); + ac_msg = temp->data; + near_ndef_set_mb_me(ac_msg->data, true, false); + } + + g_list_foreach(cfg_msgs, set_mb_me_to_false, NULL); + temp = g_list_last(cfg_msgs); + cfg_msg = temp->data; + near_ndef_set_mb_me(cfg_msg->data, false, true); + + if (type == RECORD_TYPE_WKT_HANDOVER_REQUEST) { + /* copy cr */ + memcpy(ho_msg->data + ho_msg->offset, + cr_msg->data, cr_msg->length); + ho_msg->offset += cr_msg->length; + + if (ho_msg->offset > ho_msg->length) + goto fail; + } + + /* copy acs */ + copy_ac_records(ho_msg, ac_msgs); + if (ho_msg->offset > ho_msg->length) + goto fail; + + /* + * copy cfgs, cfg (associated to the ac) records length + * (bt or wifi) is not part of Hr initial size. + */ + copy_cfg_records(ho_msg, cfg_msgs); + + DBG("Handover message preparation is done"); + + free_ndef_message(cr_msg); + g_list_free_full(ac_msgs, free_ndef_list); + g_list_free_full(cfg_msgs, free_ndef_list); + + return ho_msg; + +fail: + near_error("handover record preparation failed"); + + g_list_free_full(ac_msgs, free_ndef_list); + g_list_free_full(cfg_msgs, free_ndef_list); + free_ndef_message(cr_msg); + free_ndef_message(ho_msg); + + return NULL; +} + +/* Code to fill hr record structure from acs and mimes lists */ +static int near_fill_ho_payload(struct near_ndef_ho_payload *ho, + GSList *acs, GSList *mimes) +{ + int rec_count; + int i; + GSList *temp; + + rec_count = g_slist_length(acs); + ho->ac_payloads = g_try_malloc0(rec_count * + sizeof(struct near_ndef_ac_payload *)); + if (!ho->ac_payloads) + goto fail; + temp = acs; + for (i = 0; i < rec_count; i++) { + ho->ac_payloads[i] = temp->data; + temp = temp->next; + } + ho->number_of_ac_payloads = rec_count; + g_slist_free(acs); + + /* Same process for cfg mimes */ + rec_count = g_slist_length(mimes); + ho->cfg_payloads = g_try_malloc0(rec_count * + sizeof(struct near_ndef_mime_payload *)); + if (!ho->cfg_payloads) + goto fail; + temp = mimes; + for (i = 0; i < rec_count; i++) { + ho->cfg_payloads[i] = temp->data; + temp = temp->next; + } + + ho->number_of_cfg_payloads = rec_count; + g_slist_free(mimes); + + return 0; +fail: + g_free(ho->ac_payloads); + g_free(ho->cfg_payloads); + ho->ac_payloads = NULL; + ho->cfg_payloads = NULL; + return -ENOMEM; +} + +/* + * This function will parse an handover record payload, retrieving sub records + * like (ac, cr, er) but it will also get the associated ndefs + * (eg: handover carrier record, mime type for BT) + * In a handover frame, only the following types are expected: + * RECORD_TYPE_WKT_HANDOVER_CARRIER: + * RECORD_TYPE_WKT_COLLISION_RESOLUTION + * RECORD_TYPE_MIME_TYPE + * RECORD_TYPE_WKT_ALTERNATIVE_CARRIER + */ +static struct near_ndef_ho_payload *parse_ho_payload(enum record_type rec_type, + uint8_t *payload, uint32_t ho_length, size_t frame_length, + uint8_t ho_mb, uint8_t ho_me, struct near_ndef_message **reply) +{ + struct near_ndef_ho_payload *ho_payload = NULL; + struct near_ndef_ac_payload *ac = NULL; + struct near_ndef_mime_payload *mime = NULL; + struct carrier_data *c_data; + struct near_ndef_record *trec = NULL; + GSList *acs = NULL, *mimes = NULL, *c_datas = NULL; + uint8_t mb = 0, me = 0, i; + uint32_t offset; + int16_t count_ac = 0; + bool action = false, status; + + DBG(""); + + if (!payload) + return NULL; + offset = 0; + + /* Create the handover record payload */ + ho_payload = g_try_malloc0(sizeof(struct near_ndef_ho_payload)); + if (!ho_payload) + return NULL; + + /* Version is the first mandatory field of hr payload */ + ho_payload->version = payload[offset]; + + /* If major is different, reply with an empty Hs */ + if (HANDOVER_MAJOR(ho_payload->version) != + HANDOVER_MAJOR(HANDOVER_VERSION)) { + near_error("Unsupported version (%d)", ho_payload->version); + /* Skip parsing and return an empty record */ + if (reply) + *reply = near_ndef_prepare_empty_hs_message(); + + return ho_payload; + } + + offset = offset + 1; + + /* We should work on the whole frame */ + ho_length = frame_length; + + while (offset < ho_length) { + /* Create local record for mime parsing */ + trec = g_try_malloc0(sizeof(struct near_ndef_record)); + if (!trec) + return NULL; + + trec->header = parse_record_header(payload, offset, ho_length); + + if (!trec->header) + goto fail; + + offset = trec->header->offset; + + switch (trec->header->rec_type) { + case RECORD_TYPE_WKT_SMART_POSTER: + case RECORD_TYPE_WKT_SIZE: + case RECORD_TYPE_WKT_TEXT: + case RECORD_TYPE_WKT_TYPE: + case RECORD_TYPE_WKT_ACTION: + case RECORD_TYPE_WKT_URI: + case RECORD_TYPE_WKT_HANDOVER_REQUEST: + case RECORD_TYPE_WKT_HANDOVER_SELECT: + case RECORD_TYPE_WKT_ERROR: + case RECORD_TYPE_EXT_AAR: + case RECORD_TYPE_UNKNOWN: + break; + + case RECORD_TYPE_EMPTY: + case RECORD_TYPE_ERROR: + goto fail; + + case RECORD_TYPE_WKT_HANDOVER_CARRIER: + DBG("HANDOVER_CARRIER"); + /* + * TODO process Hc record too !!! + * Used for Wifi session + */ + break; + + case RECORD_TYPE_MIME_TYPE: + DBG("TYPE_MIME_TYPE"); + + /* check mb/me bits */ + if (validate_record_begin_and_end_bits(&ho_mb, &ho_me, + trec->header->mb, trec->header->me) != 0) { + DBG("validate mb me failed"); + goto fail; + } + + /* + * In Handover, the mime type gives bluetooth handover + * or WiFi configuration data. + * If we initiated the session, the received Hs frame + * is the signal to launch the pairing. + */ + if (rec_type == RECORD_TYPE_WKT_HANDOVER_SELECT) + action = true; + else + action = false; + + /* HO payload for reply creation */ + trec->ho = ho_payload; + + mime = parse_mime_type(trec, payload, frame_length, + offset, trec->header->payload_len, + &c_data); + trec->ho = NULL; + + if (!mime || !c_data) + goto fail; + + /* add the mime to the list */ + mimes = g_slist_append(mimes, mime); + /* add the carrier data to the list */ + c_datas = g_slist_append(c_datas, c_data); + + count_ac--; + if (count_ac == 0) + offset = ho_length; + break; + + case RECORD_TYPE_WKT_COLLISION_RESOLUTION: + DBG("COLLISION_RESOLUTION"); + + /* check nested mb/me bits */ + if (validate_record_begin_and_end_bits(&mb, &me, + trec->header->mb, trec->header->me) != 0) { + DBG("validate mb me failed"); + goto fail; + } + + ho_payload->collision_record = + near_get_be16(payload + offset); + + break; + + case RECORD_TYPE_WKT_ALTERNATIVE_CARRIER: + DBG("ALTERNATIVE_CARRIER"); + + /* check nested mb/me bits */ + if (validate_record_begin_and_end_bits(&mb, &me, + trec->header->mb, trec->header->me) != 0) { + DBG("validate mb me failed"); + goto fail; + } + + ac = parse_ac_payload(payload + offset, + trec->header->payload_len); + if (!ac) + goto fail; + + acs = g_slist_append(acs, ac); + + /* TODO check if adata are present */ + count_ac++; + break; + } + + offset += trec->header->payload_len; + g_free(trec->header->il_field); + g_free(trec->header->type_name); + g_free(trec->header); + trec->header = NULL; + + g_free(trec); + trec = NULL; + } + + /* + * In case of multiple carriers, handover with any carrier + * gets done then leave the loop. + */ + if (action) { + status = false; + count_ac = g_slist_length(mimes); + + for (i = 0; i < count_ac; i++) { + if (process_mime_type(g_slist_nth_data(mimes, i), + g_slist_nth_data(c_datas, i)) == 0) { + status = true; + break; + } + } + + if (!status) { + DBG("could not process alternative carriers"); + goto fail; + } + } else if (reply) { + /* This is a Hs with no cfg and no Ac: No reply and fail */ + if (rec_type == RECORD_TYPE_WKT_HANDOVER_SELECT && + g_slist_length(acs) == 0) { + *reply = NULL; + goto fail; + } + + /* Prepare Hs, it depends upon Hr message carrier types */ + *reply = near_ndef_prepare_hs_reply(mimes, c_datas); + if (!*reply) { + DBG("error in preparing in HS record"); + goto fail; + } + } + + if ((!acs) || (!mimes)) + return ho_payload; + + /* Save the records */ + if (near_fill_ho_payload(ho_payload, acs, mimes) < 0) + goto fail; + + DBG("handover payload parsing complete"); + + g_slist_free_full(c_datas, g_free); + + return ho_payload; + +fail: + near_error("handover payload parsing failed"); + + if (trec) { + if (trec->header) { + g_free(trec->header->type_name); + g_free(trec->header->il_field); + g_free(trec->header); + } + g_free(trec); + } + + g_slist_free_full(c_datas, g_free); + free_ho_payload(ho_payload); + + return NULL; +} + +static struct near_ndef_aar_payload * +parse_aar_payload(uint8_t *payload, uint32_t length) +{ + struct near_ndef_aar_payload *aar_payload = NULL; + + DBG(""); + + if (!payload) + return NULL; + + aar_payload = g_try_malloc0(sizeof(struct near_ndef_uri_payload)); + if (!aar_payload) + return NULL; + + aar_payload->package = g_strndup((char *)payload, length); + if (!aar_payload->package) { + near_error("AAR payload parsing failed"); + free_aar_payload(aar_payload); + return NULL; + } + + DBG("AAR package %s", aar_payload->package); + + return aar_payload; +} + +int __near_ndef_record_register(struct near_ndef_record *record, char *path) +{ + record->path = path; + + g_dbus_register_interface(connection, record->path, + NFC_RECORD_INTERFACE, + NULL, NULL, record_properties, + record, NULL); + + return 0; +} + +/* + * These functions parse a specific type record (id or mime) to find the + * associated string. + */ +bool near_ndef_record_cmp_id(struct near_ndef_record *rec1, + struct near_ndef_record *rec2) +{ + DBG(""); + + if ((!rec1) || (!rec2)) + return false; + + if ((!rec1->header) || (!rec2->header)) + return false; + + /* usual checks */ + if ((!rec1->header->il_field) || + (!rec2->header->il_field)) + return false; + + if (memcmp(rec1->header->il_field, rec2->header->il_field, + (rec1->header->il_length) > (rec2->header->il_length) + ? (rec1->header->il_length) : + (rec2->header->il_length)) != 0) + return false; + + return true; +} + +bool near_ndef_record_cmp_mime(struct near_ndef_record *rec1, + struct near_ndef_record *rec2) +{ + + DBG(""); + + if ((!rec1) || (!rec2)) + return false; + + if ((!rec1->header) || (!rec2->header)) + return false; + /* usual checks */ + if ((!rec1->mime) || (!rec2->mime)) + return false; + + if ((!rec1->mime->type) || (!rec2->mime->type)) + return false; + + if (strlen(rec1->mime->type) != strlen(rec2->mime->type)) + return false; + + if ((g_strcmp0(rec1->mime->type, rec2->mime->type) != 0)) + return false; + + return true; +} + +/* helper to get the record data length */ +size_t near_ndef_data_length(struct near_ndef_record *rec) +{ + if (!rec) + return 0; + else + return rec->data_len; +} + +/* helper to get the record data pointer */ +uint8_t *near_ndef_data_ptr(struct near_ndef_record *rec) +{ + if (!rec) + return NULL; + else + return rec->data; +} + +GList *near_ndef_parse_msg(uint8_t *ndef_data, size_t ndef_length, + struct near_ndef_message **reply) +{ + GList *records; + uint8_t p_mb = 0, p_me = 0, *record_start; + size_t offset = 0; + struct near_ndef_record *record = NULL; + struct carrier_data *c_data; + + DBG(""); + + records = NULL; + + if (!ndef_data || + ndef_length < NDEF_MSG_MIN_LENGTH) + goto fail; + + while (offset < ndef_length) { + + DBG("Record Header : 0x%X", ndef_data[offset]); + + record = g_try_malloc0(sizeof(struct near_ndef_record)); + if (!record) + goto fail; + + record->header = parse_record_header(ndef_data, offset, + ndef_length); + if (!record->header) + goto fail; + + if (validate_record_begin_and_end_bits(&p_mb, &p_me, + record->header->mb, + record->header->me) != 0) { + DBG("validate mb me failed"); + goto fail; + } + + record_start = ndef_data + offset; + offset = record->header->offset; + + switch (record->header->rec_type) { + case RECORD_TYPE_WKT_SIZE: + case RECORD_TYPE_WKT_TYPE: + case RECORD_TYPE_WKT_ACTION: + case RECORD_TYPE_WKT_HANDOVER_CARRIER: + case RECORD_TYPE_WKT_ALTERNATIVE_CARRIER: + case RECORD_TYPE_WKT_COLLISION_RESOLUTION: + case RECORD_TYPE_WKT_ERROR: + case RECORD_TYPE_UNKNOWN: + break; + + case RECORD_TYPE_EMPTY: + break; + + case RECORD_TYPE_ERROR: + goto fail; + + case RECORD_TYPE_WKT_HANDOVER_REQUEST: + case RECORD_TYPE_WKT_HANDOVER_SELECT: + /* + * Handover frame are a little bit special as the NDEF + * length (specified in the header) is not the real + * frame size. The complete frame includes extra NDEF + * following the initial handover NDEF + */ + record->ho = parse_ho_payload(record->header->rec_type, + ndef_data + offset, + record->header->payload_len, + ndef_length - offset, + record->header->mb, record->header->me, + reply); + if (!record->ho) + goto fail; + + /* the complete frame is processed, break the loop */ + record->header->payload_len = ndef_length; + break; + + case RECORD_TYPE_WKT_TEXT: + record->text = parse_text_payload(ndef_data + offset, + record->header->payload_len); + + if (!record->text) + goto fail; + + break; + + case RECORD_TYPE_WKT_URI: + record->uri = parse_uri_payload(ndef_data + offset, + record->header->payload_len); + + if (!record->uri) + goto fail; + + break; + + case RECORD_TYPE_WKT_SMART_POSTER: + record->sp = parse_sp_payload( + ndef_data + offset, + record->header->payload_len); + + if (!record->sp) + goto fail; + + break; + + case RECORD_TYPE_MIME_TYPE: + record->mime = parse_mime_type(record, ndef_data, + ndef_length, offset, + record->header->payload_len, + &c_data); + if (!record->mime) + goto fail; + + /* No carrier data, move on */ + if (!c_data) + break; + + if (process_mime_type(record->mime, c_data) < 0) { + g_free(c_data); + c_data = NULL; + goto fail; + } + + g_free(c_data); + c_data = NULL; + break; + + case RECORD_TYPE_EXT_AAR: + record->aar = parse_aar_payload(ndef_data + offset, + record->header->payload_len); + + if (!record->aar) + goto fail; + + break; + } + + record->data_len = record->header->header_len + + record->header->payload_len; + + record->data = g_try_malloc0(record->data_len); + if (!record->data) + goto fail; + + memcpy(record->data, record_start, record->data_len); + + records = g_list_append(records, record); + + build_record_type_string(record); + + offset += record->header->payload_len; + } + + return records; + +fail: + near_error("ndef parsing failed"); + free_ndef_record(record); + + return records; +} + +void near_ndef_records_free(GList *records) +{ + GList *list; + + for (list = records; list; list = list->next) { + struct near_ndef_record *record = list->data; + + __near_ndef_record_free(record); + } + + g_list_free(records); +} + +/* + * Compute ndef records length, even though the submitted frame is incomplete. + * This code is used in the handover read function, as we have to "guess" the + * final frame size. + * + * Message size for SR=1 is: + * 1 : ndef rec header (offset 0) + * x : record type length (offset 1) + * y : payload length (offset 2) 1 byte ONLY if SR=1 + * if SR=0: (4bytes) 32 bits + * z : payload id length (offset 3) ONLY if il_length=1 + * */ +int near_ndef_record_length(uint8_t *ndef_in, size_t ndef_in_length) +{ + int ndef_size; /* default size for NDEF hdr + rec typ len + payl */ + size_t offset; + uint8_t hdr; + + DBG(""); + + if (ndef_in_length < 3) + return -EINVAL; + + ndef_size = 3; + offset = 0; + + /* save header byte */ + hdr = ndef_in[offset]; + offset++; + + /* header->type_len */ + ndef_size += ndef_in[offset++]; + + /* header->payload_len */ + if (RECORD_SR_BIT(hdr) == 1) { + ndef_size += ndef_in[offset++]; + } else { + ndef_size += near_get_be32(ndef_in + offset); + offset += 4; + + if (offset >= ndef_in_length) + return -ERANGE; + } + + /* header->il */ + ndef_size += RECORD_IL_BIT(hdr); + + /* header->il_length */ + if (RECORD_IL_BIT(hdr) == 1) + ndef_size += ndef_in[offset++]; + + DBG("near_ndef_message_length is %d", ndef_size); + + return ndef_size; +} + +int near_ndef_count_records(uint8_t *ndef_in, size_t ndef_in_length, + uint8_t record_type) +{ + uint8_t p_mb = 0, p_me = 0; + int err; + size_t offset; + struct near_ndef_record *record = NULL; + int counted_records = 0 ; + + DBG(""); + + offset = 0; + + if (!ndef_in || ndef_in_length < NDEF_MSG_MIN_LENGTH) { + err = -EINVAL; + goto fail; + } + + while (offset < ndef_in_length) { + record = g_try_malloc0(sizeof(struct near_ndef_record)); + if (!record) { + err = -ENOMEM; + goto fail; + } + + /* Create a record */ + record->header = parse_record_header(ndef_in, offset, + ndef_in_length); + if (!record->header) { + err = -EINVAL; + goto fail; + } + + /* Validate MB ME */ + if (validate_record_begin_and_end_bits(&p_mb, &p_me, + record->header->mb, + record->header->me) != 0) { + DBG("validate mb me failed"); + err = -EINVAL; + goto fail; + } + + /* Is this what we want ? */ + if (record->header->rec_type == record_type) + counted_records++; + + /* Jump to the next record */ + offset = record->header->offset + record->header->payload_len; + + free_ndef_record(record); + } + + DBG("Type %d Records found: %d", record_type, counted_records); + + return counted_records; + +fail: + near_error("ndef counting failed"); + free_ndef_record(record); + return err; +} + +/* Possible encoding "UTF-8" or "UTF-16" */ +struct near_ndef_message *near_ndef_prepare_text_record(char *encoding, + char *language_code, char *text) +{ + struct near_ndef_message *msg; + uint32_t text_len, payload_length; + uint8_t code_len, status = 0; + + DBG(""); + + /* Validate input parameters*/ + if (((g_strcmp0(encoding, "UTF-8") != 0) && + (g_strcmp0(encoding, "UTF-16") != 0)) || + (!language_code) || + (!text)) { + return NULL; + } + + code_len = strlen(language_code); + text_len = strlen(text); + payload_length = 1 + code_len + text_len; + + msg = ndef_message_alloc("T", payload_length); + if (!msg) + return NULL; + + if (g_strcmp0(encoding, "UTF-16") == 0) + status |= NDEF_TEXT_RECORD_UTF16_STATUS; + + status = status | code_len; + msg->data[msg->offset++] = status; + + if (code_len > 0) + memcpy(msg->data + msg->offset, language_code, code_len); + + msg->offset += code_len; + + if (text_len > 0) + memcpy(msg->data + msg->offset, text, text_len); + + msg->offset += text_len; + + if (msg->offset > msg->length) + goto fail; + + return msg; + +fail: + near_error("text record preparation failed"); + free_ndef_message(msg); + + return NULL; +} + +struct near_ndef_message *near_ndef_prepare_uri_record(uint8_t identifier, + uint32_t field_length, uint8_t *field) +{ + struct near_ndef_message *msg = NULL; + uint32_t payload_length; + + DBG(""); + + /* Validate input parameters*/ + if ((field_length == 0 && field) || + (field_length != 0 && !field)) { + return NULL; + } + + payload_length = field_length + 1; + + msg = ndef_message_alloc("U", payload_length); + if (!msg) + return NULL; + + msg->data[msg->offset++] = identifier; + + if (field_length > 0) { + memcpy(msg->data + msg->offset, field, field_length); + msg->offset += field_length; + } + + if (msg->offset > msg->length) + goto fail; + + return msg; + +fail: + near_error("uri record preparation failed"); + free_ndef_message(msg); + + return NULL; +} + +struct near_ndef_message * +near_ndef_prepare_smartposter_record(uint8_t uri_identifier, + uint32_t uri_field_length, + uint8_t *uri_field) +{ + struct near_ndef_message *msg = NULL, *uri = NULL; + + /* URI is mandatory in Smartposter */ + uri = near_ndef_prepare_uri_record(uri_identifier, uri_field_length, + uri_field); + if (!uri) + goto fail; + + /* URI record length is equal to payload length of Sp record */ + msg = ndef_message_alloc("Sp", uri->length); + if (!msg) + goto fail; + + memcpy(msg->data + msg->offset, uri->data, uri->length); + msg->offset += uri->length; + + if (msg->offset > msg->length) + goto fail; + + free_ndef_message(uri); + + return msg; + +fail: + near_error("smartposter record preparation failed"); + + free_ndef_message(uri); + free_ndef_message(msg); + + return NULL; +} + +static char *get_text_field(DBusMessage *msg, char *text) +{ + DBusMessageIter iter, arr_iter; + char *uri = NULL; + + DBG(""); + + if (!text) + return NULL; + + dbus_message_iter_init(msg, &iter); + dbus_message_iter_recurse(&iter, &arr_iter); + + while (dbus_message_iter_get_arg_type(&arr_iter) != + DBUS_TYPE_INVALID) { + const char *key; + DBusMessageIter ent_iter; + DBusMessageIter var_iter; + + dbus_message_iter_recurse(&arr_iter, &ent_iter); + dbus_message_iter_get_basic(&ent_iter, &key); + dbus_message_iter_next(&ent_iter); + dbus_message_iter_recurse(&ent_iter, &var_iter); + + switch (dbus_message_iter_get_arg_type(&var_iter)) { + case DBUS_TYPE_STRING: + if (g_strcmp0(key, text) == 0) + dbus_message_iter_get_basic(&var_iter, &uri); + + break; + } + + dbus_message_iter_next(&arr_iter); + } + + return uri; +} + +static inline char *get_uri_field(DBusMessage *msg) +{ + return get_text_field(msg, "URI"); +} + +static GSList *get_carrier_field(DBusMessage *msg) +{ + char *carrier; + char **arr; + GSList *carriers = NULL; + uint8_t num_of_carriers, i; + + DBG(""); + + carrier = get_text_field(msg, "Carrier"); + if (!carrier) + return NULL; + + arr = g_strsplit(carrier, ",", NEAR_CARRIER_MAX); + num_of_carriers = g_strv_length(arr); + + for (i = 0; i < num_of_carriers; i++) + carriers = g_slist_append(carriers, g_strdup(arr[i])); + + g_strfreev(arr); + + return carriers; +} + +static struct near_ndef_message *build_text_record(DBusMessage *msg) +{ + DBusMessageIter iter, arr_iter; + char *cod = NULL, *lang = NULL, *rep = NULL; + + DBG(""); + + dbus_message_iter_init(msg, &iter); + dbus_message_iter_recurse(&iter, &arr_iter); + + while (dbus_message_iter_get_arg_type(&arr_iter) != + DBUS_TYPE_INVALID) { + const char *key; + DBusMessageIter ent_iter; + DBusMessageIter var_iter; + + dbus_message_iter_recurse(&arr_iter, &ent_iter); + dbus_message_iter_get_basic(&ent_iter, &key); + dbus_message_iter_next(&ent_iter); + dbus_message_iter_recurse(&ent_iter, &var_iter); + + switch (dbus_message_iter_get_arg_type(&var_iter)) { + case DBUS_TYPE_STRING: + if (g_strcmp0(key, "Encoding") == 0) + dbus_message_iter_get_basic(&var_iter, &cod); + else if (g_strcmp0(key, "Language") == 0) + dbus_message_iter_get_basic(&var_iter, &lang); + else if (g_strcmp0(key, "Representation") == 0) + dbus_message_iter_get_basic(&var_iter, &rep); + + break; + } + + dbus_message_iter_next(&arr_iter); + } + + return near_ndef_prepare_text_record(cod, lang, rep); +} + +static struct near_ndef_message *build_uri_record(DBusMessage *msg) +{ + char *uri = NULL; + const char *uri_prefix = NULL; + uint8_t id_len, i, id; + uint32_t uri_len; + + DBG(""); + + uri = get_uri_field(msg); + if (!uri) + return NULL; + + id = 0; + id_len = 0; + + for (i = 1; i <= NFC_MAX_URI_ID; i++) { + + uri_prefix = __near_ndef_get_uri_prefix(i); + if (uri_prefix && + g_str_has_prefix(uri, uri_prefix)) { + id = i; + id_len = strlen(uri_prefix); + break; + } + } + + DBG("%d %d\n", i, id_len); + + uri_len = strlen(uri) - id_len; + return near_ndef_prepare_uri_record(id, uri_len, + (uint8_t *)(uri + id_len)); +} + +static struct near_ndef_message *build_sp_record(DBusMessage *msg) +{ + char *uri = NULL; + const char *uri_prefix; + uint8_t id_len, i; + uint32_t uri_len; + + DBG(""); + + /* + * Currently this function supports only mandatory URI record, + * TODO: Other records support. + */ + uri = get_uri_field(msg); + if (!uri) + return NULL; + + for (i = 1; i <= NFC_MAX_URI_ID; i++) { + uri_prefix = __near_ndef_get_uri_prefix(i); + if (uri_prefix && + g_str_has_prefix(uri, uri_prefix)) + break; + } + + if (!uri_prefix) { + i = 0; + id_len = 0; + } else + id_len = strlen(uri_prefix); + + uri_len = strlen(uri) - id_len; + return near_ndef_prepare_smartposter_record(i, uri_len, + (uint8_t *)(uri + id_len)); +} + +static struct near_ndef_message *build_ho_record(enum record_type type, + DBusMessage *msg) +{ + struct near_ndef_message *ho; + GSList *carriers; + + DBG(""); + + carriers = get_carrier_field(msg); + ho = near_ndef_prepare_ho_message(type, carriers); + g_slist_free_full(carriers, g_free); + + return ho; +} + +static int fill_wifi_wsc_data(uint8_t *tlv, uint16_t id, + uint16_t data_len, uint8_t *data) +{ + int offset = 0; + + if (!tlv || !data) + return 0; + + fillb16(tlv, id); + offset += WIFI_WSC_ID_LENGTH; + + fillb16(tlv + offset, data_len); + offset += WIFI_WSC_ID_DATA_LENGTH; + + memcpy(tlv + offset, data, data_len); + offset += data_len; + + return offset; +} + +static void get_wsc_data(DBusMessageIter iter, char **ssid, char **pass) +{ + DBG(""); + + *ssid = NULL; + *pass = NULL; + + while (dbus_message_iter_get_arg_type(&iter) != + DBUS_TYPE_INVALID) { + const char *key; + DBusMessageIter ent_iter; + DBusMessageIter var_iter; + + dbus_message_iter_recurse(&iter, &ent_iter); + dbus_message_iter_get_basic(&ent_iter, &key); + dbus_message_iter_next(&ent_iter); + dbus_message_iter_recurse(&ent_iter, &var_iter); + + switch (dbus_message_iter_get_arg_type(&var_iter)) { + case DBUS_TYPE_STRING: + if (g_strcmp0(key, "SSID") == 0) + dbus_message_iter_get_basic(&var_iter, ssid); + else if (g_strcmp0(key, "Passphrase") == 0) + dbus_message_iter_get_basic(&var_iter, pass); + + break; + } + + dbus_message_iter_next(&iter); + } +} + +struct near_ndef_message *near_ndef_prepare_wsc_record(char *ssid, + char *passphrase) +{ + uint16_t ssid_len, pass_len, key_type; + uint8_t temp_key[2]; + uint8_t *tlv; + uint32_t tlv_len, offset; + struct near_ndef_message *mime; + + /* At least SSID is required in case of open network */ + if (!ssid) + return NULL; + + DBG("SSID %s Passphrase %s", ssid, passphrase); + + /* Prepare TLV from ssid and passphrasse */ + ssid_len = strlen(ssid); + + if (passphrase) { + pass_len = strlen(passphrase); + key_type = WIFI_WSC_KEY_PSK; + } else { + pass_len = 0; + key_type = WIFI_WSC_KEY_OPEN; + } + + /* add ssid length */ + tlv_len = WIFI_WSC_ID_LENGTH + WIFI_WSC_ID_DATA_LENGTH + ssid_len; + /* add authentication type length */ + tlv_len += WIFI_WSC_ID_LENGTH + WIFI_WSC_ID_DATA_LENGTH + 2; + /* add network key length */ + if (passphrase) + tlv_len += WIFI_WSC_ID_LENGTH + + WIFI_WSC_ID_DATA_LENGTH + pass_len; + + tlv = g_try_malloc0(tlv_len); + if (!tlv) + return NULL; + + offset = 0; + /* copy SSID */ + offset += fill_wifi_wsc_data(tlv, WIFI_WSC_ID_SSID, + ssid_len, (uint8_t *) ssid); + + /* + * copy authentication type + * copy key type to temp key array to maintain endianess + * and fill wsc data + */ + fillb16(temp_key, key_type); + offset += fill_wifi_wsc_data(tlv + offset, WIFI_WSC_ID_AUTH_TYPE, + WIFI_WSC_ID_DATA_LENGTH, + (uint8_t *) temp_key); + + /* copy Network Key */ + if (passphrase) + offset += fill_wifi_wsc_data(tlv + offset, WIFI_WSC_ID_KEY, + pass_len, + (uint8_t *) passphrase); + + mime = ndef_message_alloc_complete(WIFI_WSC_MIME_STRING, tlv_len, NULL, + 0, RECORD_TNF_MIME, true, + true); + if (!mime) { + g_free(tlv); + return NULL; + } + + memcpy(mime->data + mime->offset, tlv, tlv_len); + g_free(tlv); + + return mime; +} + +static char *get_mime_payload_data(DBusMessageIter iter, + char **payload, int *payload_len) +{ + DBG(""); + + if (!payload || !payload_len) { + near_error("Payload %p payload_len %p", payload, payload_len); + return NULL; + } + + while (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INVALID) { + const char *key; + DBusMessageIter ent_iter; + DBusMessageIter var_iter; + DBusMessageIter arr_iter; + + dbus_message_iter_recurse(&iter, &ent_iter); + dbus_message_iter_get_basic(&ent_iter, &key); + dbus_message_iter_next(&ent_iter); + dbus_message_iter_recurse(&ent_iter, &var_iter); + + if (g_strcmp0(key, "Payload") == 0) { + if (dbus_message_iter_get_arg_type(&var_iter) == + DBUS_TYPE_ARRAY && + dbus_message_iter_get_element_type(&var_iter) == + DBUS_TYPE_BYTE) { + dbus_message_iter_recurse(&var_iter, + &arr_iter); + dbus_message_iter_get_fixed_array( + &arr_iter, payload, + payload_len); + } else { + near_error("Unexpected payload type"); + return NULL; + } + } + dbus_message_iter_next(&iter); + } + + return *payload; +} + +static struct near_ndef_message *near_ndef_prepare_mime_payload_record( + char *type, char *payload, int payload_len) +{ + struct near_ndef_message *mime; + + DBG("Payload %*s", payload_len, payload); + mime = ndef_message_alloc_complete(type, payload_len, NULL, 0, + RECORD_TNF_MIME, true, true); + if (!mime) { + near_error("Failed to alloc NDEF message"); + return NULL; + } + + memcpy(mime->data + mime->offset, payload, payload_len); + + return mime; +} + +static struct near_ndef_message *build_mime_record(DBusMessage *msg) +{ + DBusMessageIter iter, arr_iter; + char *key, *mime_str, *ssid, *passphrase; + + DBG(""); + + dbus_message_iter_init(msg, &iter); + dbus_message_iter_recurse(&iter, &arr_iter); + + while (dbus_message_iter_get_arg_type(&arr_iter) != + DBUS_TYPE_INVALID) { + DBusMessageIter ent_iter; + DBusMessageIter var_iter; + + dbus_message_iter_recurse(&arr_iter, &ent_iter); + dbus_message_iter_get_basic(&ent_iter, &key); + + if (g_strcmp0(key, "MIME") == 0) { + dbus_message_iter_next(&ent_iter); + dbus_message_iter_recurse(&ent_iter, &var_iter); + dbus_message_iter_get_basic(&var_iter, &mime_str); + + if (g_strcmp0(mime_str, WIFI_WSC_MIME_STRING) == 0) { + struct near_ndef_message *mime; + struct carrier_data *carrier; + + get_wsc_data(arr_iter, &ssid, &passphrase); + if (ssid) + return near_ndef_prepare_wsc_record( + ssid, passphrase); + + /* + * If we did not get an SSID and optionally + * a passphrase from the DBus message, then + * we try to get one from the WiFi-WSC agent. + */ + carrier = __near_agent_handover_request_data( + HO_AGENT_WIFI, NULL); + if (!carrier) + return NULL; + + mime = ndef_message_alloc_complete( + WIFI_WSC_MIME_STRING, carrier->size, + NULL, 0, RECORD_TNF_MIME, true, true); + if (!mime) { + g_free(carrier); + return NULL; + } + + memcpy(mime->data + mime->offset, + carrier->data, carrier->size); + + g_free(carrier); + + return mime; + } else { + /* + * Expect data is set in the Payload field of + * message. + */ + DBusMessageIter payload_iter; + char *payload; + int payload_len; + + DBG("mime string %s", mime_str); + dbus_message_iter_recurse(&iter, &payload_iter); + if (!get_mime_payload_data(payload_iter, + &payload, &payload_len)) + return NULL; + + return near_ndef_prepare_mime_payload_record( + mime_str, payload, payload_len); + } + } + + dbus_message_iter_next(&arr_iter); + } + + return NULL; +} + +struct near_ndef_message *__ndef_build_from_message(DBusMessage *msg) +{ + DBusMessageIter iter; + DBusMessageIter arr_iter; + struct near_ndef_message *ndef; + + DBG(""); + + dbus_message_iter_init(msg, &iter); + dbus_message_iter_recurse(&iter, &arr_iter); + + ndef = NULL; + + while (dbus_message_iter_get_arg_type(&arr_iter) != + DBUS_TYPE_INVALID) { + const char *key, *value; + DBusMessageIter ent_iter; + DBusMessageIter var_iter; + + dbus_message_iter_recurse(&arr_iter, &ent_iter); + dbus_message_iter_get_basic(&ent_iter, &key); + + if (g_strcmp0(key, "Type") != 0) { + dbus_message_iter_next(&arr_iter); + continue; + } + + dbus_message_iter_next(&ent_iter); + dbus_message_iter_recurse(&ent_iter, &var_iter); + + switch (dbus_message_iter_get_arg_type(&var_iter)) { + case DBUS_TYPE_STRING: + dbus_message_iter_get_basic(&var_iter, &value); + + if (g_strcmp0(value, "Text") == 0) { + ndef = build_text_record(msg); + break; + } else if (g_strcmp0(value, "URI") == 0) { + ndef = build_uri_record(msg); + break; + } else if (g_strcmp0(value, "SmartPoster") == 0) { + ndef = build_sp_record(msg); + break; + } else if (g_strcmp0(value, "Handover") == 0) { + ndef = build_ho_record( + RECORD_TYPE_WKT_HANDOVER_REQUEST, msg); + break; + } else if (g_strcmp0(value, "StaticHandover") == 0) { + ndef = build_ho_record( + RECORD_TYPE_WKT_HANDOVER_SELECT, msg); + break; + } else if (g_strcmp0(value, "MIME") == 0) { + ndef = build_mime_record(msg); + break; + } else { + near_error("%s not supported", value); + ndef = NULL; + break; + } + + break; + } + + dbus_message_iter_next(&arr_iter); + } + + return ndef; +} + +int __near_ndef_init(void) +{ + DBG(""); + + connection = near_dbus_get_connection(); + + return 0; +} + +void __near_ndef_cleanup(void) +{ +}
diff --git a/neard/src/near.h b/neard/src/near.h new file mode 100644 index 0000000..d64dc30 --- /dev/null +++ b/neard/src/near.h
@@ -0,0 +1,259 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <stdint.h> +#include <stdbool.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <glib.h> + +#include <near/nfc_copy.h> +#include <near/types.h> + +struct near_adapter; +struct near_device_driver; + +#include <near/log.h> + +int __near_log_init(const char *debug, gboolean detach); +void __near_log_cleanup(void); + +#include <near/dbus.h> + +int __near_dbus_init(DBusConnection *conn); +void __near_dbus_cleanup(void); + +DBusMessage *__near_error_failed(DBusMessage *msg, int errnum); +DBusMessage *__near_error_invalid_arguments(DBusMessage *msg); +DBusMessage *__near_error_out_of_memory(DBusMessage *msg); +DBusMessage *__near_error_permission_denied(DBusMessage *msg); +DBusMessage *__near_error_passphrase_required(DBusMessage *msg); +DBusMessage *__near_error_not_registered(DBusMessage *msg); +DBusMessage *__near_error_not_unique(DBusMessage *msg); +DBusMessage *__near_error_not_supported(DBusMessage *msg); +DBusMessage *__near_error_not_implemented(DBusMessage *msg); +DBusMessage *__near_error_not_found(DBusMessage *msg); +DBusMessage *__near_error_not_polling(DBusMessage *msg); +DBusMessage *__near_error_no_carrier(DBusMessage *msg); +DBusMessage *__near_error_in_progress(DBusMessage *msg); +DBusMessage *__near_error_already_exists(DBusMessage *msg); +DBusMessage *__near_error_already_enabled(DBusMessage *msg); +DBusMessage *__near_error_already_disabled(DBusMessage *msg); +DBusMessage *__near_error_already_connected(DBusMessage *msg); +DBusMessage *__near_error_not_connected(DBusMessage *msg); +DBusMessage *__near_error_operation_aborted(DBusMessage *msg); +DBusMessage *__near_error_operation_timeout(DBusMessage *msg); +DBusMessage *__near_error_invalid_service(DBusMessage *msg); +DBusMessage *__near_error_invalid_property(DBusMessage *msg); +DBusMessage *__near_error_io_error(DBusMessage *msg); +DBusMessage *__near_error_no_space_left(DBusMessage *msg); + +int __near_manager_adapter_add(uint32_t idx, const char *name, + uint32_t protocols, bool powered); +void __near_manager_adapter_remove(uint32_t idx); +int __near_manager_init(DBusConnection *conn); +void __near_manager_cleanup(void); + +#include <near/adapter.h> + +struct near_adapter *__near_adapter_create(uint32_t idx, + const char *name, uint32_t protocols, bool powered); +void __near_adapter_destroy(struct near_adapter *adapter); +const char *__near_adapter_get_path(struct near_adapter *adapter); +struct near_adapter *__near_adapter_get(uint32_t idx); +int __near_adapter_add(struct near_adapter *adapter); +void __near_adapter_remove(struct near_adapter *adapter); +int __near_adapter_add_target(uint32_t idx, uint32_t target_idx, + uint32_t protocols, uint16_t sens_res, uint8_t sel_res, + uint8_t *nfcid, uint8_t nfcid_len, + uint8_t iso15693_dsfid, + uint8_t iso15693_uid_len, uint8_t *iso15693_uid); +int __near_adapter_remove_target(uint32_t idx, uint32_t target_idx); +int __near_adapter_get_targets_done(uint32_t idx); +int __near_adapter_add_device(uint32_t idx, uint8_t *nfcid, uint8_t nfcid_len); +int __near_adapter_remove_device(uint32_t idx); +int __near_adapter_set_dep_state(uint32_t idx, bool dep); +bool __near_adapter_get_dep_state(uint32_t idx); +void __near_adapter_listen(struct near_device_driver *driver); +void __near_adapter_start_check_presence(uint32_t adapter_idx, uint32_t target_idx); +void __near_adapter_stop_check_presence(uint32_t adapter_idx, uint32_t target_idx); +int __near_adapter_init(void); +void __near_adapter_cleanup(void); + +#include <near/ndef.h> + +#define NFC_MAX_URI_ID 0x23 + +int __near_ndef_init(void); +void __near_ndef_cleanup(void); +int __near_ndef_record_register(struct near_ndef_record *record, char *path); +void __near_ndef_record_free(struct near_ndef_record *record); +char *__near_ndef_record_get_path(struct near_ndef_record *record); +char *__near_ndef_record_get_type(struct near_ndef_record *record); +uint8_t *__near_ndef_record_get_data(struct near_ndef_record *record, size_t *len); +uint8_t *__near_ndef_record_get_payload(struct near_ndef_record *record, size_t *len); +void __near_ndef_append_records(DBusMessageIter *iter, GList *record); +const char *__near_ndef_get_uri_prefix(uint8_t id); +struct near_ndef_message *__ndef_build_from_message(DBusMessage *msg); + +#include <near/snep.h> + +int __near_snep_core_init(void); +void __near_snep_core_cleanup(void); + +#include <near/tag.h> + +int __near_tag_init(void); +void __near_tag_cleanup(void); +struct near_tag *__near_tag_add(uint32_t adapter_idx, uint32_t target_idx, + uint32_t protocols, + uint16_t sens_res, uint8_t sel_res, + uint8_t *nfcid, uint8_t nfcid_len, + uint8_t iso15693_dsfid, + uint8_t iso15693_uid_len, + uint8_t *iso15693_uid); +void __near_tag_remove(struct near_tag *tag); +const char *__near_tag_get_path(struct near_tag *tag); +uint32_t __near_tag_get_type(struct near_tag *tag); +void __near_tag_append_records(struct near_tag *tag, DBusMessageIter *iter); +int __near_tag_read(struct near_tag *tag, near_tag_io_cb cb); +int __near_tag_write(struct near_tag *tag, + struct near_ndef_message *ndef, + near_tag_io_cb cb); +int __near_tag_check_presence(struct near_tag *tag, near_tag_io_cb cb); + +#include <near/device.h> + +int __near_device_init(void); +void __near_device_cleanup(void); +const char *__near_device_get_path(struct near_device *device); +uint32_t __neard_device_get_idx(struct near_device *device); +struct near_device *__near_device_add(uint32_t idx, uint32_t target_idx, + uint8_t *nfcid, uint8_t nfcid_len); +void __near_device_remove(struct near_device *device); +bool __near_device_register_interface(struct near_device *device); +int __near_device_listen(struct near_device *device, near_device_io_cb cb); +int __near_device_push(struct near_device *device, + struct near_ndef_message *ndef, char *service_name, + near_device_io_cb cb); + +#include <near/tlv.h> + +int __near_netlink_get_adapters(void); +int __near_netlink_start_poll(int idx, + uint32_t im_protocols, uint32_t tm_protocols); +int __near_netlink_stop_poll(int idx); +int __near_netlink_dep_link_up(uint32_t idx, uint32_t target_idx, + uint8_t comm_mode, uint8_t rf_mode); +int __near_netlink_dep_link_down(uint32_t idx); +int __near_netlink_adapter_enable(int idx, bool enable); +int __near_netlink_send_vendor_cmd(int idx, guint32 oui, guint32 sub_cmd, + guint32 data_len, guint8 *data); +int __near_netlink_init(void); +void __near_netlink_cleanup(void); + +#include <near/setting.h> + +#include <near/plugin.h> + +int __near_plugin_init(const char *pattern, const char *exclude); +void __near_plugin_cleanup(void); + +/* NFC Bluetooth Secure Simple Pairing */ +#define BT_MIME_V2_0 0 +#define BT_MIME_V2_1 1 +#define WIFI_WSC_MIME 2 +#define BT_MIME_STRING_2_0 "nokia.com:bt" +#define BT_MIME_STRING_2_1 "application/vnd.bluetooth.ep.oob" +#define WIFI_WSC_MIME_STRING "application/vnd.wfa.wsc" + +/* Mime specific properties */ +#define OOB_PROPS_EMPTY 0x00 +#define OOB_PROPS_SP_HASH 0x01 +#define OOB_PROPS_SP_RANDOM 0x02 +#define OOB_PROPS_SHORT_NAME 0x04 +#define OOB_PROPS_COD 0x08 +#define OOB_PROPS_SP (OOB_PROPS_SP_HASH | OOB_PROPS_SP_RANDOM) + +/* Handover Agent Carrier Types */ +#define NEAR_HANDOVER_AGENT_BLUETOOTH "bluetooth" +#define NEAR_HANDOVER_AGENT_WIFI "wifi" + +#define NEAR_CARRIER_MAX 2 + +#define WIFI_WSC_ID_SSID 0x1045 +#define WIFI_WSC_ID_AUTH_TYPE 0x1003 +#define WIFI_WSC_ID_KEY 0x1027 +#define WIFI_WSC_KEY_OPEN 0x0001 +#define WIFI_WSC_KEY_PSK 0x0022 +#define WIFI_WSC_ID_LENGTH 2 +#define WIFI_WSC_ID_DATA_LENGTH 2 + +/* near_ndef_handover_carrier*/ +enum handover_carrier { + NEAR_CARRIER_EMPTY = 0x00, + NEAR_CARRIER_BLUETOOTH = 0x01, /* bit 0 */ + NEAR_CARRIER_WIFI = 0x02, /* bit 1 */ + NEAR_CARRIER_UNKNOWN = 0x80, /* Bit 7 */ +}; + +enum carrier_power_state { + CPS_INACTIVE = 0x00, + CPS_ACTIVE = 0x01, + CPS_ACTIVATING = 0x02, + CPS_UNKNOWN = 0x03, +}; + +enum ho_agent_carrier { + HO_AGENT_BT = 0x00, + HO_AGENT_WIFI = 0x01, + HO_AGENT_UNKNOWN = 0xFF +}; + +struct carrier_data { + uint8_t type; + uint8_t size; + enum carrier_power_state state; + uint8_t data[UINT8_MAX]; +}; + +int __near_bluetooth_init(void); +void __near_bluetooth_cleanup(void); +void __near_bluetooth_legacy_start(void); +void __near_bluetooth_legacy_stop(void); +int __near_bluetooth_parse_oob_record(struct carrier_data *data, + uint16_t *properties, bool pair); +int __near_bluetooth_pair(void *data); +struct carrier_data *__near_bluetooth_local_get_properties(uint16_t mime_props); + +void __near_agent_ndef_parse_records(GList *records); +bool __near_agent_handover_registered(enum ho_agent_carrier carrier); + +struct carrier_data *__near_agent_handover_request_data( + enum ho_agent_carrier carrier, + struct carrier_data *data); +int __near_agent_handover_push_data(enum ho_agent_carrier carrier, + struct carrier_data *data); + +int __near_agent_init(void); +void __near_agent_cleanup(void);
diff --git a/neard/src/neard.service.in b/neard/src/neard.service.in new file mode 100644 index 0000000..dfa238c --- /dev/null +++ b/neard/src/neard.service.in
@@ -0,0 +1,12 @@ +[Unit] +Description=neard service +Documentation=man:neard(8) + +[Service] +Type=dbus +BusName=org.neard +ExecStart=@pkglibexecdir@/neard -n +LimitNPROC=1 + +[Install] +Alias=dbus-org.neard.service
diff --git a/neard/src/netlink.c b/neard/src/netlink.c new file mode 100644 index 0000000..923fb7d --- /dev/null +++ b/neard/src/netlink.c
@@ -0,0 +1,1009 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright 2007, 2008 Johannes Berg <johannes@sipsolutions.net> + * Copyright (C) 2011 Instituto Nokia de Tecnologia + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> + +#include <netlink/netlink.h> +#include <netlink/genl/genl.h> +#include <netlink/genl/family.h> +#include <netlink/genl/ctrl.h> + +#include "near.h" + +#ifdef NEED_LIBNL_COMPAT +#define nl_sock nl_handle + +static inline struct nl_handle *nl_socket_alloc(void) +{ + return nl_handle_alloc(); +} + +static inline void nl_socket_free(struct nl_sock *h) +{ + nl_handle_destroy(h); +} + +#define NLE_MISSING_ATTR 14 + +static inline void __nl_perror(int error, const char *s) +{ + nl_perror(s); +} +#define nl_perror __nl_perror +#endif + +struct nlnfc_state { + struct nl_sock *cmd_sock; + struct nl_sock *event_sock; + int nfc_id; + int mcid; +}; + +static struct nlnfc_state *nfc_state; +static GIOChannel *netlink_channel = NULL; + +struct send_msg_data { + void *data; + int *done; + int (*finish_handler)(struct nl_msg *, void *); +}; + +static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, + void *arg) +{ + int *ret = arg; + + DBG(""); + + *ret = err->error; + + return NL_STOP; +} + +static int __finish_handler(struct nl_msg *msg, void *arg) +{ + struct send_msg_data *data = arg; + + + DBG(""); + + if (data->finish_handler) + data->finish_handler(msg, data->data); + + *(data->done) = 1; + + return NL_SKIP; +} + +static int ack_handler(struct nl_msg *msg, void *arg) +{ + int *ret = arg; + + DBG(""); + + *ret = 1; + + return NL_STOP; +} + +static int __nl_send_msg(struct nl_sock *sock, struct nl_msg *msg, + int (*rx_handler)(struct nl_msg *, void *), + int (*finish_handler)(struct nl_msg *, void *), + void *data) +{ + struct nl_cb *cb; + int err, done; + struct send_msg_data send_data; + + DBG(""); + + cb = nl_cb_alloc(NL_CB_DEFAULT); + if (!cb) + return -ENOMEM; + + err = nl_send_auto_complete(sock, msg); + if (err < 0) { + nl_cb_put(cb); + near_error("%s", strerror(err)); + + return err; + } + + err = done = 0; + send_data.done = &done; + send_data.data = data; + send_data.finish_handler = finish_handler; + + nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, __finish_handler, &send_data); + nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err); + nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &done); + + if (rx_handler) + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, rx_handler, data); + + while (err == 0 && done == 0) + nl_recvmsgs(sock, cb); + + nl_cb_put(cb); + + return err; +} + +static inline int nl_send_msg(struct nl_sock *sock, struct nl_msg *msg, + int (*rx_handler)(struct nl_msg *, void *), + void *data) +{ + return __nl_send_msg(sock, msg, rx_handler, NULL, data); +} + +static int get_devices_handler(struct nl_msg *n, void *arg) +{ + struct nlmsghdr *nlh = nlmsg_hdr(n); + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + char *name; + uint32_t idx, protocols; + bool powered; + + DBG(""); + + genlmsg_parse(nlh, 0, attrs, NFC_ATTR_MAX, NULL); + + if (!attrs[NFC_ATTR_DEVICE_INDEX] || + !attrs[NFC_ATTR_DEVICE_NAME] || + !attrs[NFC_ATTR_PROTOCOLS]) { + nl_perror(NLE_MISSING_ATTR, "NFC_CMD_GET_DEVICE"); + return NL_STOP; + } + + idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + name = nla_get_string(attrs[NFC_ATTR_DEVICE_NAME]); + protocols = nla_get_u32(attrs[NFC_ATTR_PROTOCOLS]); + + if (!attrs[NFC_ATTR_DEVICE_POWERED]) + powered = false; + else + powered = nla_get_u8(attrs[NFC_ATTR_DEVICE_POWERED]); + + __near_manager_adapter_add(idx, name, protocols, powered); + + return NL_SKIP; +} + +int __near_netlink_get_adapters(void) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + if (!nfc_state || nfc_state->nfc_id < 0) + return -ENODEV; + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_DUMP, NFC_CMD_GET_DEVICE, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto out; + } + + err = nl_send_msg(nfc_state->cmd_sock, msg, get_devices_handler, NULL); + +out: + nlmsg_free(msg); + + return err; +} + +int __near_netlink_start_poll(int idx, + uint32_t im_protocols, uint32_t tm_protocols) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG("IM protos 0x%x TM protos 0x%x", im_protocols, tm_protocols); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_START_POLL, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx); + if (im_protocols != 0) { + NLA_PUT_U32(msg, NFC_ATTR_IM_PROTOCOLS, im_protocols); + NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, im_protocols); + } + if (tm_protocols != 0) + NLA_PUT_U32(msg, NFC_ATTR_TM_PROTOCOLS, tm_protocols); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int __near_netlink_stop_poll(int idx) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_STOP_POLL, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int __near_netlink_dep_link_up(uint32_t idx, uint32_t target_idx, + uint8_t comm_mode, uint8_t rf_mode) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_DEP_LINK_UP, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx); + NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target_idx); + NLA_PUT_U8(msg, NFC_ATTR_COMM_MODE, comm_mode); + NLA_PUT_U8(msg, NFC_ATTR_RF_MODE, rf_mode); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int __near_netlink_dep_link_down(uint32_t idx) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_DEP_LINK_DOWN, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int __near_netlink_adapter_enable(int idx, bool enable) +{ + struct nl_msg *msg; + void *hdr; + int err; + uint8_t cmd; + + DBG(""); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + if (enable) + cmd = NFC_CMD_DEV_UP; + else + cmd = NFC_CMD_DEV_DOWN; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, cmd, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int __near_netlink_send_vendor_cmd(int idx, guint32 oui, guint32 sub_cmd, + guint32 data_len, guint8 *data) +{ + struct nl_msg *msg; + struct nl_data *nl_data_buffer; + void *hdr; + int err; + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_VENDOR, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx); + NLA_PUT_U32(msg, NFC_ATTR_VENDOR_ID, oui); + NLA_PUT_U32(msg, NFC_ATTR_VENDOR_SUBCMD, sub_cmd); + nl_data_buffer = nl_data_alloc(data, data_len); + if (!nl_data_buffer) { + err = -ENOMEM; + goto nla_put_failure; + } + + err = nla_put_data(msg, NFC_ATTR_VENDOR_DATA, nl_data_buffer); + if (err < 0) + goto nla_fail_free_data; + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_fail_free_data: + nl_data_free(nl_data_buffer); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static int no_seq_check(struct nl_msg *n, void *arg) +{ + DBG(""); + + return NL_OK; +} + +static int nfc_netlink_event_adapter(struct genlmsghdr *gnlh, bool add) +{ + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + uint32_t idx; + + DBG(""); + + nla_parse(attrs, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + if (!attrs[NFC_ATTR_DEVICE_INDEX]) { + near_error("Missing device index"); + return -ENODEV; + } + + idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + + if (add && + (!attrs[NFC_ATTR_DEVICE_NAME] || + !attrs[NFC_ATTR_PROTOCOLS])) { + near_error("Missing attributes"); + return -EINVAL; + } + + if (add) { + char *name; + uint32_t protocols; + bool powered; + + name = nla_get_string(attrs[NFC_ATTR_DEVICE_NAME]); + protocols = nla_get_u32(attrs[NFC_ATTR_PROTOCOLS]); + if (!attrs[NFC_ATTR_DEVICE_POWERED]) + powered = false; + else + powered = nla_get_u8(attrs[NFC_ATTR_DEVICE_POWERED]); + + return __near_manager_adapter_add(idx, name, + protocols, powered); + } else { + __near_manager_adapter_remove(idx); + } + + return 0; +} + +static int get_targets_handler(struct nl_msg *n, void *arg) +{ + struct nlmsghdr *nlh = nlmsg_hdr(n); + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + uint32_t adapter_idx, target_idx, protocols; + uint16_t sens_res = 0; + uint8_t sel_res = 0; + uint8_t nfcid[NFC_MAX_NFCID1_LEN], nfcid_len; + uint8_t iso15693_dsfid = 0; + uint8_t iso15693_uid_len, iso15693_uid[NFC_MAX_ISO15693_UID_LEN]; + + DBG(""); + + genlmsg_parse(nlh, 0, attrs, NFC_ATTR_MAX, NULL); + + adapter_idx = *((uint32_t *)arg); + target_idx = nla_get_u32(attrs[NFC_ATTR_TARGET_INDEX]); + protocols = nla_get_u32(attrs[NFC_ATTR_PROTOCOLS]); + + if (attrs[NFC_ATTR_TARGET_SENS_RES]) + sens_res = + nla_get_u16(attrs[NFC_ATTR_TARGET_SENS_RES]); + + if (attrs[NFC_ATTR_TARGET_SEL_RES]) + sel_res = + nla_get_u16(attrs[NFC_ATTR_TARGET_SEL_RES]); + + if (attrs[NFC_ATTR_TARGET_NFCID1]) { + nfcid_len = nla_len(attrs[NFC_ATTR_TARGET_NFCID1]); + if (nfcid_len <= NFC_MAX_NFCID1_LEN) + memcpy(nfcid, nla_data(attrs[NFC_ATTR_TARGET_NFCID1]), + nfcid_len); + } else { + nfcid_len = 0; + } + + if (attrs[NFC_ATTR_TARGET_ISO15693_DSFID]) + iso15693_dsfid = + nla_get_u8(attrs[NFC_ATTR_TARGET_ISO15693_DSFID]); + + if (attrs[NFC_ATTR_TARGET_ISO15693_UID]) { + iso15693_uid_len = nla_len(attrs[NFC_ATTR_TARGET_ISO15693_UID]); + if (iso15693_uid_len == NFC_MAX_ISO15693_UID_LEN) + memcpy(iso15693_uid, + nla_data(attrs[NFC_ATTR_TARGET_ISO15693_UID]), + NFC_MAX_ISO15693_UID_LEN); + } else { + iso15693_uid_len = 0; + } + + DBG("target idx %d proto 0x%x sens_res 0x%x sel_res 0x%x NFCID len %d", + target_idx, protocols, sens_res, sel_res, nfcid_len); + DBG("\tiso15693_uid_len %d", iso15693_uid_len); + + __near_adapter_add_target(adapter_idx, target_idx, protocols, + sens_res, sel_res, nfcid, nfcid_len, + iso15693_dsfid, + iso15693_uid_len, iso15693_uid); + + return 0; +} + +static int get_targets_finish_handler(struct nl_msg *n, void *arg) +{ + uint32_t adapter_idx; + + DBG(""); + + adapter_idx = *((uint32_t *)arg); + + return __near_adapter_get_targets_done(adapter_idx); +} + +static int nfc_netlink_event_targets_found(struct genlmsghdr *gnlh) +{ + struct nlattr *attr[NFC_ATTR_MAX + 1]; + struct nl_msg *msg; + void *hdr; + int err; + uint32_t adapter_idx; + + DBG(""); + + nla_parse(attr, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + if (!attr[NFC_ATTR_DEVICE_INDEX]) + return -ENODEV; + + adapter_idx = nla_get_u32(attr[NFC_ATTR_DEVICE_INDEX]); + + DBG("adapter %d", adapter_idx); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_DUMP, NFC_CMD_GET_TARGET, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, adapter_idx); + + err = __nl_send_msg(nfc_state->cmd_sock, msg, + get_targets_handler, get_targets_finish_handler, + &adapter_idx); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static int nfc_netlink_event_target_lost(struct genlmsghdr *gnlh) +{ + struct nlattr *attr[NFC_ATTR_MAX + 1]; + uint32_t adapter_idx, target_idx; + + DBG(""); + + nla_parse(attr, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (!attr[NFC_ATTR_DEVICE_INDEX]) + return -ENODEV; + + if (!attr[NFC_ATTR_TARGET_INDEX]) + return -ENODEV; + + adapter_idx = nla_get_u32(attr[NFC_ATTR_DEVICE_INDEX]); + target_idx = nla_get_u32(attr[NFC_ATTR_TARGET_INDEX]); + + DBG("adapter %d target %d", adapter_idx, target_idx); + + return __near_adapter_remove_target(adapter_idx, target_idx); +} + +static int nfc_netlink_event_dep_up(struct genlmsghdr *gnlh) +{ + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + uint32_t idx, target_idx = 0; + uint8_t rf_mode; + + DBG(""); + + nla_parse(attrs, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + if (!attrs[NFC_ATTR_DEVICE_INDEX]) { + near_error("Missing device index"); + return -ENODEV; + } + + if (!attrs[NFC_ATTR_COMM_MODE] || + !attrs[NFC_ATTR_RF_MODE]) { + near_error("Missing rf or comm modes"); + return -ENODEV; + } + + idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + rf_mode = nla_get_u8(attrs[NFC_ATTR_RF_MODE]); + + if (rf_mode == NFC_RF_INITIATOR) { + if (!attrs[NFC_ATTR_TARGET_INDEX]) { + near_error("Missing target index"); + return -ENODEV; + }; + + target_idx = nla_get_u32(attrs[NFC_ATTR_TARGET_INDEX]); + + DBG("%d %d", idx, target_idx); + + return __near_adapter_set_dep_state(idx, true); + } else { + return -EOPNOTSUPP; + } +} + +static int nfc_netlink_event_dep_down(struct genlmsghdr *gnlh) +{ + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + uint32_t idx; + + DBG(""); + + nla_parse(attrs, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + if (!attrs[NFC_ATTR_DEVICE_INDEX]) { + near_error("Missing device index"); + return -ENODEV; + } + + idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + + __near_adapter_set_dep_state(idx, false); + + return 0; +} + +static int nfc_netlink_event_tm_activated(struct genlmsghdr *gnlh) +{ + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + uint32_t idx; + + DBG(""); + + nla_parse(attrs, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + if (!attrs[NFC_ATTR_DEVICE_INDEX]) { + near_error("Missing device index"); + return -ENODEV; + } + + idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + + DBG("%d", idx); + + return __near_adapter_add_device(idx, NULL, 0); +} + +static int nfc_netlink_event_tm_deactivated(struct genlmsghdr *gnlh) +{ + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + uint32_t idx; + + DBG(""); + + nla_parse(attrs, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + if (!attrs[NFC_ATTR_DEVICE_INDEX]) { + near_error("Missing device index"); + return -ENODEV; + } + + idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + + DBG("%d", idx); + + return __near_adapter_remove_device(idx); +} + +static int nfc_netlink_event(struct nl_msg *n, void *arg) +{ + struct sockaddr_nl *src = nlmsg_get_src(n); + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(n)); + + DBG("event 0x%x", gnlh->cmd); + + if (src->nl_pid) { + near_error("WARNING: Wrong netlink message sender %d", + src->nl_pid); + return NL_SKIP; + } + + switch (gnlh->cmd) { + case NFC_EVENT_TARGETS_FOUND: + DBG("Targets found"); + nfc_netlink_event_targets_found(gnlh); + break; + case NFC_EVENT_TARGET_LOST: + DBG("Target lost"); + nfc_netlink_event_target_lost(gnlh); + break; + case NFC_EVENT_DEVICE_ADDED: + DBG("Adapter added"); + nfc_netlink_event_adapter(gnlh, true); + + break; + case NFC_EVENT_DEVICE_REMOVED: + DBG("Adapter removed"); + nfc_netlink_event_adapter(gnlh, false); + + break; + case NFC_CMD_DEP_LINK_UP: + DBG("DEP link is up"); + nfc_netlink_event_dep_up(gnlh); + + break; + case NFC_CMD_DEP_LINK_DOWN: + DBG("DEP link is down"); + nfc_netlink_event_dep_down(gnlh); + + break; + case NFC_EVENT_TM_ACTIVATED: + DBG("Target mode activated"); + nfc_netlink_event_tm_activated(gnlh); + + break; + case NFC_EVENT_TM_DEACTIVATED: + DBG("Target mode deactivated"); + nfc_netlink_event_tm_deactivated(gnlh); + + break; + } + + return NL_SKIP; +} + +static gboolean __nfc_netlink_event(GIOChannel *channel, + GIOCondition cond, gpointer data) +{ + struct nl_cb *cb; + struct nlnfc_state *state = data; + + if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) + return FALSE; + + cb = nl_cb_alloc(NL_CB_VERBOSE); + if (!cb) + return TRUE; + + nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, nfc_netlink_event, data); + + nl_recvmsgs(state->event_sock, cb); + + nl_cb_put(cb); + + return TRUE; +} + +static int nfc_event_listener(struct nlnfc_state *state) +{ + int sock; + + sock = nl_socket_get_fd(state->event_sock); + netlink_channel = g_io_channel_unix_new(sock); + g_io_channel_set_close_on_unref(netlink_channel, TRUE); + + g_io_channel_set_encoding(netlink_channel, NULL, NULL); + g_io_channel_set_buffered(netlink_channel, FALSE); + + g_io_add_watch(netlink_channel, + G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR, + __nfc_netlink_event, state); + + return 0; +} + +struct handler_args { + const char *group; + int id; +}; + +static int family_handler(struct nl_msg *msg, void *arg) +{ + struct handler_args *grp = arg; + struct nlattr *tb[CTRL_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *mcgrp; + int rem_mcgrp; + + DBG(""); + + nla_parse(tb, CTRL_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (!tb[CTRL_ATTR_MCAST_GROUPS]) + return NL_SKIP; + + nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], rem_mcgrp) { + struct nlattr *tb_mcgrp[CTRL_ATTR_MCAST_GRP_MAX + 1]; + + nla_parse(tb_mcgrp, CTRL_ATTR_MCAST_GRP_MAX, + nla_data(mcgrp), nla_len(mcgrp), NULL); + + if (!tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME] || + !tb_mcgrp[CTRL_ATTR_MCAST_GRP_ID]) + continue; + if (strncmp(nla_data(tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME]), + grp->group, nla_len(tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME]))) + continue; + grp->id = nla_get_u32(tb_mcgrp[CTRL_ATTR_MCAST_GRP_ID]); + break; + } + + return NL_SKIP; +} + +static int nl_get_multicast_id(struct nl_sock *sock, const char *family, + const char *group) +{ + struct nl_msg *msg; + int err, ctrlid; + struct handler_args grp = { + .group = group, + .id = -ENOENT, + }; + + DBG(""); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + ctrlid = genl_ctrl_resolve(sock, "nlctrl"); + + genlmsg_put(msg, 0, 0, ctrlid, 0, 0, CTRL_CMD_GETFAMILY, 0); + + err = -EMSGSIZE; + + NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, family); + + err = nl_send_msg(sock, msg, family_handler, &grp); + if (err) + goto nla_put_failure; + + DBG("multicast id %d", grp.id); + + err = grp.id; + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int __near_netlink_init(void) +{ + int err; + + DBG(""); + + nfc_state = g_try_malloc0(sizeof(struct nlnfc_state)); + if (!nfc_state) + return -ENOMEM; + + nfc_state->cmd_sock = nl_socket_alloc(); + if (!nfc_state->cmd_sock) { + near_error("Failed to allocate NFC command netlink socket"); + err = -ENOMEM; + goto state_free; + } + + nfc_state->event_sock = nl_socket_alloc(); + if (!nfc_state->event_sock) { + near_error("Failed to allocate NFC event netlink socket"); + err = -ENOMEM; + goto handle_cmd_destroy; + } + + if (genl_connect(nfc_state->cmd_sock)) { + near_error("Failed to connect to generic netlink"); + err = -ENOLINK; + goto handle_event_destroy; + } + + if (genl_connect(nfc_state->event_sock)) { + near_error("Failed to connect to generic netlink"); + err = -ENOLINK; + goto handle_event_destroy; + } + + nfc_state->nfc_id = genl_ctrl_resolve(nfc_state->cmd_sock, "nfc"); + if (nfc_state->nfc_id < 0) { + near_error("Unable to find NFC netlink family"); + err = -ENOENT; + goto handle_event_destroy; + } + + nfc_state->mcid = nl_get_multicast_id(nfc_state->cmd_sock, NFC_GENL_NAME, + NFC_GENL_MCAST_EVENT_NAME); + if (nfc_state->mcid <= 0) { + near_error("Wrong mcast id %d", nfc_state->mcid); + err = nfc_state->mcid; + goto handle_event_destroy; + } + + err = nl_socket_add_membership(nfc_state->event_sock, nfc_state->mcid); + if (err) { + near_error("Error adding nl event socket to membership"); + goto handle_event_destroy; + } + + return nfc_event_listener(nfc_state); + +handle_event_destroy: + nl_socket_free(nfc_state->event_sock); + +handle_cmd_destroy: + nl_socket_free(nfc_state->cmd_sock); + +state_free: + g_free(nfc_state); + + nfc_state = NULL; + + near_error("netlink init failed"); + + return err; +} + +void __near_netlink_cleanup(void) +{ + if (netlink_channel) { + g_io_channel_shutdown(netlink_channel, TRUE, NULL); + g_io_channel_unref(netlink_channel); + + netlink_channel = NULL; + } + + if (!nfc_state) + return; + + nl_socket_free(nfc_state->cmd_sock); + nl_socket_free(nfc_state->event_sock); + + g_free(nfc_state); + + DBG(""); +}
diff --git a/neard/src/org.neard.conf b/neard/src/org.neard.conf new file mode 100644 index 0000000..0844322 --- /dev/null +++ b/neard/src/org.neard.conf
@@ -0,0 +1,18 @@ +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + <policy user="root"> + <allow own="org.neard"/> + <allow send_destination="org.neard"/> + <allow send_interface="org.neard.NDEFAgent"/> + <allow send_interface="org.neard.PHDC.Manager"/> + <allow send_interface="org.neard.PHDC.Agent"/> + <allow send_interface="org.neard.HandoverAgent"/> + </policy> + <policy at_console="true"> + <allow send_destination="org.neard"/> + </policy> + <policy context="default"> + <deny send_destination="org.neard"/> + </policy> +</busconfig>
diff --git a/neard/src/plugin.c b/neard/src/plugin.c new file mode 100644 index 0000000..efa6594 --- /dev/null +++ b/neard/src/plugin.c
@@ -0,0 +1,206 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <dlfcn.h> + +#include <glib.h> + +#ifdef NEAR_PLUGIN_BUILTIN +#undef NEAR_PLUGIN_BUILTIN +#endif + +#include "near.h" + +static GSList *plugins = NULL; + +struct near_plugin { + void *handle; + bool active; + struct near_plugin_desc *desc; +}; + +static gint compare_priority(gconstpointer a, gconstpointer b) +{ + const struct near_plugin *plugin1 = a; + const struct near_plugin *plugin2 = b; + + return plugin2->desc->priority - plugin1->desc->priority; +} + +static bool add_plugin(void *handle, struct near_plugin_desc *desc) +{ + struct near_plugin *plugin; + + if (!desc->init) + return false; + + if (!g_str_equal(desc->version, NEAR_VERSION)) { + near_error("Version mismatch for %s", desc->description); + return false; + } + + plugin = g_try_new0(struct near_plugin, 1); + if (!plugin) + return false; + + plugin->handle = handle; + plugin->active = false; + plugin->desc = desc; + + plugins = g_slist_insert_sorted(plugins, plugin, compare_priority); + + return true; +} + +static bool check_plugin(struct near_plugin_desc *desc, + char **patterns, char **excludes) +{ + if (excludes) { + for (; *excludes; excludes++) + if (g_pattern_match_simple(*excludes, desc->name)) + break; + if (*excludes) { + near_info("Excluding %s", desc->description); + return false; + } + } + + if (patterns) { + for (; *patterns; patterns++) + if (g_pattern_match_simple(*patterns, desc->name)) + break; + if (!*patterns) { + near_info("Ignoring %s", desc->description); + return false; + } + } + + return true; +} + +#include <builtin.h> + +int __near_plugin_init(const char *pattern, const char *exclude) +{ + gchar **patterns = NULL; + gchar **excludes = NULL; + GSList *list; + GDir *dir; + const gchar *file; + gchar *filename; + unsigned int i; + + DBG(""); + + if (pattern) + patterns = g_strsplit_set(pattern, ":, ", -1); + + if (exclude) + excludes = g_strsplit_set(exclude, ":, ", -1); + + for (i = 0; __near_builtin[i]; i++) { + if (!check_plugin(__near_builtin[i], patterns, excludes)) + continue; + + add_plugin(NULL, __near_builtin[i]); + } + + dir = g_dir_open(PLUGINDIR, 0, NULL); + if (dir) { + while ((file = g_dir_read_name(dir))) { + void *handle; + struct near_plugin_desc *desc; + + if (g_str_has_prefix(file, "lib") || + !g_str_has_suffix(file, ".so")) + continue; + + filename = g_build_filename(PLUGINDIR, file, NULL); + + handle = dlopen(filename, RTLD_NOW); + if (!handle) { + near_error("Can't load %s: %s", + filename, dlerror()); + g_free(filename); + continue; + } + + g_free(filename); + + desc = dlsym(handle, "near_plugin_desc"); + if (!desc) { + near_error("Can't load symbol: %s", + dlerror()); + dlclose(handle); + continue; + } + + if (!check_plugin(desc, patterns, excludes)) { + dlclose(handle); + continue; + } + + if (!add_plugin(handle, desc)) + dlclose(handle); + } + + g_dir_close(dir); + } + + for (list = plugins; list; list = list->next) { + struct near_plugin *plugin = list->data; + + if (plugin->desc->init() < 0) + continue; + + plugin->active = true; + } + + g_strfreev(patterns); + g_strfreev(excludes); + + return 0; +} + +void __near_plugin_cleanup(void) +{ + GSList *list; + + DBG(""); + + for (list = plugins; list; list = list->next) { + struct near_plugin *plugin = list->data; + + if (plugin->active && plugin->desc->exit) + plugin->desc->exit(); + + if (plugin->handle) + dlclose(plugin->handle); + + g_free(plugin); + } + + g_slist_free(plugins); +}
diff --git a/neard/src/snep.c b/neard/src/snep.c new file mode 100644 index 0000000..c0a1d1a --- /dev/null +++ b/neard/src/snep.c
@@ -0,0 +1,871 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdint.h> +#include <errno.h> +#include <string.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/plugin.h> +#include <near/types.h> +#include <near/adapter.h> +#include <near/device.h> +#include <near/ndef.h> +#include <near/tlv.h> +#include <near/snep.h> + +#include "near.h" + +struct snep_fragment { + uint32_t len; + uint8_t *data; +}; + +struct p2p_snep_put_req_data { + uint8_t fd; + uint32_t adapter_idx; + uint32_t target_idx; + near_device_io_cb cb; + guint watch; + + GSList *fragments; +}; + +struct p2p_snep_req_frame { + uint8_t version; + uint8_t request; + uint32_t length; + uint8_t ndef[]; +} __attribute__((packed)); + +struct p2p_snep_resp_frame { + uint8_t version; + uint8_t response; + uint32_t length; + uint8_t info[]; +} __attribute__((packed)); + +static GHashTable *snep_client_hash; + +/* Callback: free snep data */ +static void free_snep_core_client(gpointer data) +{ + struct p2p_snep_data *snep_data = data; + + DBG(""); + + g_free(snep_data->nfc_data); + g_free(snep_data); +} + +/* Send a short response code */ +void near_snep_core_response_noinfo(int client_fd, uint8_t response) +{ + struct p2p_snep_resp_frame resp; + + DBG("Response 0x%x", response); + + resp.version = NEAR_SNEP_VERSION; + resp.response = response; + resp.length = 0; + + send(client_fd, &resp, sizeof(resp), 0); +} + +/* + * near_snep_core_parse_handover_record + * + * The hr frame should be here BUT: + * The first 4 bytes are the Max Allowed Length + * + * - Because of an Android's BUGs: + * - the Hr frame is not correct; a Hr record + * is embedded in a ... Hr record !!! The author + * used 'Hr' instead of 'cr' + * - The OOB block is badly written: + * - the payload ID should be the same in the 'ac' record + * and the OOB record. + * - The OOB data length bytes must be swapped (Big endian to Little E.) + * + * The hack fixes the first issue (bluetooth.c fixes the second) ! + * */ +void near_snep_core_parse_handover_record(int client_fd, uint8_t *ndef, + uint32_t nfc_data_length) +{ + GList *records; + struct near_ndef_message *msg = NULL; + + if (!ndef) + return; + + /* + * Bugfix Android: Fix 'cr' instead of 'Hr' + * Bug is in Google:HandoverManager.java:645 + */ + if (nfc_data_length > 9 && strncmp((char *)(ndef + 9), "Hr", 2) == 0) { + DBG("Android 4.1.1 found !!!"); + *(ndef + 9) = 'c'; + } + + /* Parse the incoming frame */ + records = near_ndef_parse_msg(ndef, nfc_data_length, &msg); + if (!records) + return; + + near_ndef_records_free(records); + + if (!msg) + return; + + near_info("Send SNEP / Hs frame"); + + near_snep_core_response_with_info(client_fd, NEAR_SNEP_RESP_SUCCESS, + msg->data, msg->length); + + g_free(msg->data); + g_free(msg); +} + +/* + * This code will read the ndef message. + * return <0 on error + * ==0 if not more bytes + * >0 if there's still some data to read + */ +static int snep_core_read_ndef(int client_fd, + struct p2p_snep_data *snep_data) +{ + int bytes_recv, remaining_bytes; + + DBG(""); + + remaining_bytes = snep_data->nfc_data_length - + snep_data->nfc_data_current_length; + + bytes_recv = recv(client_fd, snep_data->nfc_data_ptr, remaining_bytes, + MSG_DONTWAIT); + if (bytes_recv < 0) { + near_error("%d %s", bytes_recv, strerror(errno)); + + /* Some more data should show up */ + if (errno == EAGAIN) + return EAGAIN; /* Positive !!*/ + + goto out; + } + + snep_data->nfc_data_current_length += bytes_recv; + snep_data->nfc_data_ptr += bytes_recv; + + /* Is the read complete ? */ + if (snep_data->nfc_data_length == snep_data->nfc_data_current_length) + return 0; + + if (!snep_data->respond_continue) { + snep_data->respond_continue = TRUE; + near_snep_core_response_noinfo(client_fd, NEAR_SNEP_RESP_CONTINUE); + } + + return 1; + +out: + g_hash_table_remove(snep_client_hash, GINT_TO_POINTER(client_fd)); + + return -errno; /* Negative on error */ +} + +static void free_snep_core_fragment(gpointer data) +{ + struct snep_fragment *fragment = data; + + if (fragment) + g_free(fragment->data); + + g_free(fragment); + fragment = NULL; +} + +static void free_snep_core_push_data(gpointer userdata, int status) +{ + struct p2p_snep_put_req_data *data; + + DBG(""); + + if (!userdata) + return; + + data = (struct p2p_snep_put_req_data *) userdata; + + close(data->fd); + + if (data->cb) + data->cb(data->adapter_idx, data->target_idx, status); + + if (data->watch > 0) + g_source_remove(data->watch); + + g_slist_free_full(data->fragments, free_snep_core_fragment); + g_free(data); +} + +static int snep_core_send_fragment(struct p2p_snep_put_req_data *req) +{ + struct snep_fragment *fragment; + int err; + + DBG(""); + + if (!req || !req->fragments || + g_slist_length(req->fragments) == 0) + return -EINVAL; + + fragment = req->fragments->data; + + err = send(req->fd, fragment->data, fragment->len, 0); + + req->fragments = g_slist_remove(req->fragments, fragment); + g_free(fragment->data); + g_free(fragment); + + return err; +} + +static int snep_core_push_response(struct p2p_snep_put_req_data *req) +{ + struct p2p_snep_resp_frame frame; + uint8_t *ndef; + uint32_t ndef_len; + int bytes_recv, err; + + DBG(""); + + bytes_recv = recv(req->fd, &frame, sizeof(frame), 0); + if (bytes_recv < 0) { + near_error("Read SNEP frame error %d %s", bytes_recv, + strerror(errno)); + return bytes_recv; + } + + /* Check frame length */ + frame.length = g_ntohl(frame.length); + + DBG("Response 0x%x %p", frame.response, &frame); + switch (frame.response) { + case NEAR_SNEP_RESP_CONTINUE: + while (g_slist_length(req->fragments) != 0) { + err = snep_core_send_fragment(req); + if (err < 0) + return err; + } + + return frame.response; + + case NEAR_SNEP_RESP_SUCCESS: + if (frame.length == 0) + return 0; + + /* Get the incoming data */ + ndef_len = frame.length; + ndef = g_try_malloc0(ndef_len); + if (!ndef) + return -ENOMEM; + + bytes_recv = recv(req->fd, ndef, ndef_len, 0); + if (bytes_recv < 0) { + near_error("Read SNEP frame error: %d %s", bytes_recv, + strerror(errno)); + return bytes_recv; + } + + /* Not enough bytes */ + if (bytes_recv < 6) + return -EINVAL; + + if (strncmp((char *)(ndef + 3), "Hs", 2) == 0) + near_snep_core_parse_handover_record(req->fd, ndef, + ndef_len); + + g_free(ndef); + + return 0; + } + + return -1; +} + +static gboolean snep_core_push_event(GIOChannel *channel, + GIOCondition condition, gpointer data) +{ + int err; + + DBG("push_event condition 0x%x", condition); + + if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { + + near_error("Error with SNEP channel"); + + free_snep_core_push_data(data, -1); + + return FALSE; + } + + err = snep_core_push_response(data); + if (err <= 0) { + free_snep_core_push_data(data, err); + + return FALSE; + } + + return TRUE; +} + +static int snep_core_push_prepare_fragments(struct p2p_snep_put_req_data *req, + struct near_ndef_message *ndef) +{ + struct snep_fragment *fragment; + uint32_t max_fragment_len; + + DBG(""); + + max_fragment_len = NEAR_SNEP_REQ_MAX_FRAGMENT_LENGTH; + + while (ndef->offset < ndef->length) { + + fragment = g_try_malloc0(sizeof(struct snep_fragment)); + if (!fragment) + return -ENOMEM; + + if (max_fragment_len <= (ndef->length - ndef->offset)) + fragment->len = max_fragment_len; + else + fragment->len = ndef->length - ndef->offset; + + fragment->data = g_try_malloc0(fragment->len); + if (!fragment->data) { + g_free(fragment); + return -ENOMEM; + } + + memcpy(fragment->data, ndef->data + ndef->offset, + fragment->len); + ndef->offset += fragment->len; + req->fragments = g_slist_append(req->fragments, fragment); + } + + return 0; +} + +static bool snep_core_process_request(int client_fd, + struct p2p_snep_data *snep_data, + near_server_io req_get, + near_server_io req_put) +{ + bool ret; + int err; + + DBG("request %d", snep_data->request); + + /* Now, we process the request code */ + switch (snep_data->request) { + case NEAR_SNEP_REQ_PUT: + DBG("NEAR_SNEP_REQ_PUT"); + if (req_put) + ret = (*req_put)(client_fd, snep_data); + else { + near_snep_core_response_noinfo(client_fd, + NEAR_SNEP_RESP_NOT_IMPL); + ret = true; + } + + /* free and leave */ + g_hash_table_remove(snep_client_hash, + GINT_TO_POINTER(client_fd)); + break; + + case NEAR_SNEP_REQ_GET: + DBG("NEAR_SNEP_REQ_GET"); + if (req_get) + ret = (*req_get)(client_fd, snep_data); + else { + near_snep_core_response_noinfo(client_fd, + NEAR_SNEP_RESP_NOT_IMPL); + ret = true; + } + + /* If there's some fragments, don't delete before the CONT */ + if (!snep_data->req) { + /* free and leave */ + DBG("Clean Table"); + g_hash_table_remove(snep_client_hash, + GINT_TO_POINTER(client_fd)); + } + break; + + case NEAR_SNEP_REQ_REJECT: + DBG("NEAR_SNEP_REQ_REJECT"); + if (!snep_data->req->fragments) { + near_error("error: NEAR_SNEP_REQ_REJECT but no fragment"); + ret = false; + } + else { + ret = true; + } + + g_slist_free_full(snep_data->req->fragments, + free_snep_core_fragment); + g_slist_free(snep_data->req->fragments); + + g_hash_table_remove(snep_client_hash, + GINT_TO_POINTER(client_fd)); + + break; + + case NEAR_SNEP_REQ_CONTINUE: + /* + * NEAR_SNEP_REQ_CONTINUE indicates that we have to send the + * remaining fragments... + */ + + if (!snep_data->req) { + ret = true; + break; + } + + DBG("NEAR_SNEP_REQ_CONTINUE"); + if (!snep_data->req->fragments) { + near_error("error: NEAR_SNEP_REQ_CONTINUE but no fragment"); + ret = false; + goto leave_cont; + } + + /* Send fragments, one after the other (no ack expected) */ + while (g_slist_length(snep_data->req->fragments) != 0) { + err = snep_core_send_fragment(snep_data->req); + if (err < 0) { + ret = false; + goto leave_cont; + } + } + + ret = true; + +leave_cont: + /* No more fragment to send, clean memory */ + g_slist_free_full(snep_data->req->fragments, + free_snep_core_fragment); + g_slist_free(snep_data->req->fragments); + + g_hash_table_remove(snep_client_hash, + GINT_TO_POINTER(client_fd)); + + break; + + default: + near_error("Unsupported SNEP request code"); + ret = false; + break; + } + + return ret; +} + +/* + * SNEP Core: read function + * This function handles SNEP REQUEST codes: + * GET, PUT and CONTINUE (REJECT is not handled). + * + * We read the first 6 bytes (the header) and check + * - the read size ( should be 6 ) + * - the version (on MAJOR) + * + * Then, we check snep_data. If it exists, it means that we are in + * a fragment/continue situation (a 1st fragment was sent, and we + * expect a CONTINUE for the remaining bytes). + * If there's no existing snep_data, we create a new one and read the + * missing bytes (llcp removes fragmentation issues) + * + */ +bool near_snep_core_read(int client_fd, + uint32_t adapter_idx, uint32_t target_idx, + near_tag_io_cb cb, + near_server_io req_get, + near_server_io req_put, + gpointer data) +{ + struct p2p_snep_data *snep_data; + struct p2p_snep_req_frame frame; + int bytes_recv, ret; + uint32_t ndef_length; + + DBG(""); + + /* Check previous/pending snep_data */ + snep_data = g_hash_table_lookup(snep_client_hash, + GINT_TO_POINTER(client_fd)); + + /* + * If snep data is already there, and there are more bytes to read + * we just go ahead and read more fragments from the client. + */ + if (snep_data && + snep_data->nfc_data_length != + snep_data->nfc_data_current_length) { + ret = snep_core_read_ndef(client_fd, snep_data); + if (ret) + return ret; + + goto process_request; + } + + /* + * We already got something from this client, we should try + * to continue reading. + */ + /* TODO Try with PEEK */ + bytes_recv = recv(client_fd, &frame, sizeof(frame), 0); + if (bytes_recv < 0) { + near_error("Read error SNEP %d %s", bytes_recv, + strerror(errno)); + return false; + } + + /* Check frame size */ + if (bytes_recv != sizeof(frame)) { + near_error("Bad frame size: %d", bytes_recv); + return false; + } + + /* If major is different, send UNSUPPORTED VERSION */ + if (NEAR_SNEP_MAJOR(frame.version) != NEAR_SNEP_MAJOR(NEAR_SNEP_VERSION)) { + near_error("Unsupported version (%d)", frame.version); + near_snep_core_response_noinfo(client_fd, NEAR_SNEP_RESP_VERSION); + return true; + } + + /* + * This is a fragmentation SNEP operation since we have pending + * frames. But the ndef length and the current data length are + * identical. So this is a CONTINUE for a fragmented GET, and + * we should just process a CONTINUE frame and send the fragments + * back to the client. This will be done from snep_core_process_request(). + */ + if (snep_data) { + snep_data->request = frame.request; + goto process_request; + } + + /* This is a new request from the client */ + snep_data = g_try_malloc0(sizeof(struct p2p_snep_data)); + if (!snep_data) + return false; + + /* the whole frame length */ + ndef_length = GINT_FROM_BE(frame.length); + + snep_data->nfc_data = g_try_malloc0(ndef_length + TLV_SIZE); + if (!snep_data->nfc_data) { + g_free(snep_data); + return false; + } + + /* fill the struct */ + snep_data->nfc_data_length = ndef_length; + snep_data->nfc_data_ptr = snep_data->nfc_data; + snep_data->adapter_idx = adapter_idx; + snep_data->target_idx = target_idx; + snep_data->request = frame.request; + snep_data->respond_continue = FALSE; + snep_data->cb = cb; + + /* Add to the client hash table */ + g_hash_table_insert(snep_client_hash, + GINT_TO_POINTER(client_fd), snep_data); + + if (ndef_length > 0) { + if ((frame.request == NEAR_SNEP_REQ_GET) || + (frame.request == NEAR_SNEP_REQ_PUT)) { + /* We should read the missing bytes */ + ret = snep_core_read_ndef(client_fd, snep_data); + if (ret) + return ret; + } + } + +process_request: + return snep_core_process_request(client_fd, snep_data, + req_get, req_put); + +} + +/* + * send a response frame with some datas. If the frame is too long, we + * have to fragment the frame, using snep fragmentation protocol. + * Return: + * < 0 if error + * 0 if no fragment; + * > 0 if there's still some fragments + * + */ +static int near_snep_core_response(int fd, struct p2p_snep_put_req_data *req, + uint8_t resp_code, struct near_ndef_message *ndef) +{ + struct p2p_snep_req_frame header; + struct snep_fragment *fragment; + uint32_t max_fragment_len; + bool fragmenting; + int err; + int snep_req_header_length, snep_additional_length; + + DBG("resp: 0x%02X", resp_code); + + max_fragment_len = NEAR_SNEP_REQ_MAX_FRAGMENT_LENGTH; + header.version = NEAR_SNEP_VERSION; + + if (resp_code == NEAR_SNEP_REQ_GET) { /* Get for android */ + snep_req_header_length = NEAR_SNEP_REQ_GET_HEADER_LENGTH; + snep_additional_length = 4; /* 4 Acceptable Length */ + } else { + snep_req_header_length = NEAR_SNEP_REQ_PUT_HEADER_LENGTH; + snep_additional_length = 0; + } + + header.length = GUINT32_TO_BE(ndef->length + snep_additional_length); + header.request = resp_code; + + fragment = g_try_malloc0(sizeof(struct snep_fragment)); + + if (!fragment) { + err = -ENOMEM; + goto error; + } + + if (max_fragment_len >= (ndef->length + snep_req_header_length)) { + fragment->len = ndef->length + snep_req_header_length; + fragmenting = false; + } else { + fragment->len = max_fragment_len; + fragmenting = true; + } + + fragment->data = g_try_malloc0(fragment->len); + if (!fragment->data) { + g_free(fragment); + err = ENOMEM; + goto error; + } + + /* Header to data - common header */ + memcpy(fragment->data, (uint8_t *)&header, NEAR_SNEP_REQ_PUT_HEADER_LENGTH); + + /* if GET, we add the Acceptable length */ + if (header.request == NEAR_SNEP_REQ_GET) + near_put_be32(snep_req_header_length, + fragment->data + NEAR_SNEP_REQ_PUT_HEADER_LENGTH); + + if (fragmenting) { + memcpy(fragment->data + snep_req_header_length, ndef->data, + max_fragment_len - snep_req_header_length); + ndef->offset = max_fragment_len - snep_req_header_length; + + err = snep_core_push_prepare_fragments(req, ndef); + if (err < 0) { + g_free(fragment->data); + g_free(fragment); + goto error; + } + } else { + memcpy(fragment->data + snep_req_header_length, + ndef->data, ndef->length); + } + + err = send(fd, fragment->data, fragment->len, 0); + if (err < 0) { + near_error("Sending failed %d", err); + g_free(fragment->data); + g_free(fragment); + goto error; + } + + g_free(fragment->data); + g_free(fragment); + + return 0; + +error: + if (req) + free_snep_core_push_data(req, err); + + return err; +} + +void near_snep_core_response_with_info(int client_fd, uint8_t response, + uint8_t *data, int length) +{ + struct p2p_snep_data *snep_data; + struct p2p_snep_put_req_data *req; + struct near_ndef_message *ndef; + + DBG("Response with info 0x%x (len:%d)", response, length); + + req = NULL; + ndef = NULL; + + /* get the snep data */ + snep_data = g_hash_table_lookup(snep_client_hash, + GINT_TO_POINTER(client_fd)); + if (!snep_data) { + DBG("snep_data not found"); + goto done; + } + + /* Prepare the ndef struct */ + ndef = g_try_malloc0(sizeof(struct near_ndef_message)); + if (!ndef) + goto done; + + ndef->data = g_try_malloc0(length); + if (!ndef->data) { + g_free(ndef); + ndef = NULL; + goto done; + } + + /* Fill the ndef */ + ndef->length = length; + ndef->offset = 0; + memcpy(ndef->data, data, length); + + ndef->offset = 0; + + /* Now prepare req struct */ + req = g_try_malloc0(sizeof(struct p2p_snep_put_req_data)); + if (!req) + goto done; + + /* Prepare the callback */ + snep_data->req = req; + + req->fd = client_fd; + req->adapter_idx = snep_data->adapter_idx; + req->target_idx = snep_data->target_idx; + req->cb = snep_data->cb; + + /* send it !*/ + near_snep_core_response(client_fd, req, response, ndef); + +done: + /* If no fragment, free mem */ + if (req) { + if (req->fragments == 0) { + g_free(req); + snep_data->req = NULL; + } + } + + if (ndef) + g_free(ndef->data); + g_free(ndef); +} + +/* SNEP Core: on P2P push */ +int near_snep_core_push(int fd, uint32_t adapter_idx, uint32_t target_idx, + struct near_ndef_message *ndef, + near_device_io_cb cb, + gpointer data) +{ + struct p2p_snep_put_req_data *req; + GIOChannel *channel; + uint8_t resp_code; + int err; + + DBG(""); + + req = g_try_malloc0(sizeof(struct p2p_snep_put_req_data)); + if (!req) { + err = -ENOMEM; + goto error; + } + + channel = g_io_channel_unix_new(fd); + g_io_channel_set_close_on_unref(channel, TRUE); + + req->fd = fd; + req->adapter_idx = adapter_idx; + req->target_idx = target_idx; + req->cb = cb; + ndef->offset = 0; + req->watch = g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_NVAL | + G_IO_ERR, snep_core_push_event, + (gpointer) req); + + /* Check if Hr or Hs for Handover over SNEP */ + if (*(char *)(ndef->data + 3) == 'H') + resp_code = NEAR_SNEP_REQ_GET; /* Get for android */ + else + resp_code = NEAR_SNEP_REQ_PUT; + + return near_snep_core_response(fd, req, resp_code, ndef); + +error: + free_snep_core_push_data(req, err); + + return err; + +} + +/* SNEP core functions: close */ +void near_snep_core_close(int client_fd, int err, gpointer data) +{ + struct p2p_snep_data *snep_data; + + DBG(""); + + snep_data = g_hash_table_lookup(snep_client_hash, + GINT_TO_POINTER(client_fd)); + if (!snep_data) + return; + + snep_data->cb(snep_data->adapter_idx, snep_data->target_idx, err); + + g_hash_table_remove(snep_client_hash, GINT_TO_POINTER(client_fd)); +} + +int __near_snep_core_init(void) +{ + snep_client_hash = g_hash_table_new_full(g_direct_hash, + g_direct_equal, NULL, + free_snep_core_client); + + return 0; +} + +void __near_snep_core_cleanup(void) +{ + g_hash_table_destroy(snep_client_hash); + snep_client_hash = NULL; +}
diff --git a/neard/src/tag.c b/neard/src/tag.c new file mode 100644 index 0000000..d5ce973 --- /dev/null +++ b/neard/src/tag.c
@@ -0,0 +1,1220 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <string.h> + +#include <glib.h> + +#include <gdbus.h> + +#include "near.h" + +#define TYPE3_IDM_LEN 8 +#define TYPE3_ATTR_BLOCK_SIZE 16 + +struct near_tag { + char *path; + + uint32_t adapter_idx; + uint32_t target_idx; + + uint32_t protocol; + uint32_t type; + enum near_tag_sub_type sub_type; + enum near_tag_memory_layout layout; + bool readonly; + + uint8_t nfcid[NFC_MAX_NFCID1_LEN]; + uint8_t nfcid_len; + + uint8_t iso15693_dsfid; + uint8_t iso15693_uid[NFC_MAX_ISO15693_UID_LEN]; + + size_t data_length; + uint8_t *data; + + uint32_t next_record; + GList *records; + bool blank; + + /* Tag specific structures */ + struct { + uint8_t IDm[TYPE3_IDM_LEN]; + uint8_t attr[TYPE3_ATTR_BLOCK_SIZE]; + uint8_t ic_type; + } t3; + + struct { + uint16_t max_ndef_size; + uint16_t c_apdu_max_size; + uint16_t r_apdu_max_size; + uint16_t file_id; + } t4; + + struct { + uint8_t blk_size; + uint8_t num_blks; + } t5; + + DBusMessage *write_msg; /* Pending write message */ + struct near_ndef_message *write_ndef; +}; + +static DBusConnection *connection = NULL; + +static GHashTable *tag_hash; + +static GSList *driver_list = NULL; + +struct near_tag *near_tag_get_tag(uint32_t adapter_idx, uint32_t target_idx) +{ + struct near_tag *tag; + char *path; + + path = g_strdup_printf("%s/nfc%d/tag%d", NFC_PATH, + adapter_idx, target_idx); + if (!path) + return NULL; + + tag = g_hash_table_lookup(tag_hash, path); + g_free(path); + + /* TODO refcount */ + return tag; +} + +static void append_records(DBusMessageIter *iter, void *user_data) +{ + struct near_tag *tag = user_data; + GList *list; + + DBG(""); + + for (list = tag->records; list; list = list->next) { + struct near_ndef_record *record = list->data; + char *path; + + path = __near_ndef_record_get_path(record); + if (!path) + continue; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, + &path); + } +} + +static const char *type_string(struct near_tag *tag) +{ + const char *type; + + DBG("type 0x%x", tag->type); + + switch (tag->type) { + case NFC_PROTO_JEWEL: + type = "Type 1"; + break; + + case NFC_PROTO_MIFARE: + type = "Type 2"; + break; + + case NFC_PROTO_FELICA: + type = "Type 3"; + break; + + case NFC_PROTO_ISO14443: + case NFC_PROTO_ISO14443_B: + type = "Type 4"; + break; + + case NFC_PROTO_ISO15693: + type = "Type 5"; + break; + + default: + type = NULL; + near_error("Unknown tag type 0x%x", tag->type); + break; + } + + return type; +} + +static const char *protocol_string(struct near_tag *tag) +{ + const char *protocol; + + DBG("protocol 0x%x", tag->protocol); + + switch (tag->protocol) { + case NFC_PROTO_FELICA_MASK: + protocol = "Felica"; + break; + + case NFC_PROTO_MIFARE_MASK: + protocol = "MIFARE"; + break; + + case NFC_PROTO_JEWEL_MASK: + protocol = "Jewel"; + break; + + case NFC_PROTO_ISO14443_MASK: + case NFC_PROTO_ISO14443_B_MASK: + protocol = "ISO-DEP"; + break; + + case NFC_PROTO_ISO15693_MASK: + protocol = "ISO-15693"; + break; + + default: + near_error("Unknown tag protocol 0x%x", tag->protocol); + protocol = NULL; + } + + return protocol; +} + +static gboolean property_get_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_tag *tag = user_data; + const char *type; + + type = type_string(tag); + if (!type) + return FALSE; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &type); + + return TRUE; +} + +static gboolean property_get_protocol(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_tag *tag = user_data; + const char *protocol; + + protocol = protocol_string(tag); + if (!protocol) + return FALSE; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &protocol); + + return TRUE; +} + +static gboolean property_get_readonly(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_tag *tag = user_data; + dbus_bool_t readonly; + + readonly = tag->readonly; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &readonly); + + return TRUE; +} + +static gboolean property_get_adapter(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + struct near_tag *tag = user_data; + struct near_adapter *adapter; + const char *path; + + adapter = __near_adapter_get(tag->adapter_idx); + if (!adapter) + return FALSE; + + path = __near_adapter_get_path(adapter); + if (!path) + return FALSE; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); + + return TRUE; + +} + +static void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status) +{ + struct near_tag *tag; + + tag = near_tag_get_tag(adapter_idx, target_idx); + + if (!tag) + return; + + if (tag->write_msg) { + dbus_message_unref(tag->write_msg); + tag->write_msg = NULL; + } + + __near_adapter_start_check_presence(adapter_idx, target_idx); +} + +static void write_cb(uint32_t adapter_idx, uint32_t target_idx, int status) +{ + struct near_tag *tag; + DBusConnection *conn; + DBusMessage *reply; + + DBG("Write status %d", status); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + return; + + conn = near_dbus_get_connection(); + if (!conn) + goto out; + + if (status != 0) { + if (tag->write_msg) { + reply = __near_error_failed(tag->write_msg, -status); + if (reply) + g_dbus_send_message(conn, reply); + } + } else { + g_dbus_send_reply(conn, tag->write_msg, DBUS_TYPE_INVALID); + } + + near_ndef_records_free(tag->records); + tag->records = NULL; + g_free(tag->data); + tag->data = NULL; + + if (status == 0) { + /* + * If writing succeeded, + * check presence will be restored after reading + */ + __near_tag_read(tag, tag_read_cb); + return; + } + +out: + if (tag->write_msg) { + dbus_message_unref(tag->write_msg); + tag->write_msg = NULL; + } + __near_adapter_start_check_presence(tag->adapter_idx, tag->target_idx); +} + +static void format_cb(uint32_t adapter_idx, uint32_t target_idx, int status) +{ + struct near_tag *tag; + int err; + + DBG("format status %d", status); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + return; + + if (!tag->write_msg) + return; + + if (status == 0) { + err = __near_tag_write(tag, tag->write_ndef, + write_cb); + if (err < 0) + goto error; + } else { + err = status; + goto error; + } + + return; + +error: + write_cb(tag->adapter_idx, tag->target_idx, err); +} + +static DBusMessage *write_ndef(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct near_tag *tag = data; + struct near_ndef_message *ndef, *ndef_with_header = NULL; + int tlv_len_size, err; + + DBG("conn %p", conn); + + if (tag->readonly) { + DBG("Read only tag"); + return __near_error_permission_denied(msg); + } + + if (tag->write_msg) + return __near_error_in_progress(msg); + + ndef = __ndef_build_from_message(msg); + if (!ndef) + return __near_error_failed(msg, EINVAL); + + tag->write_msg = dbus_message_ref(msg); + + /* Add NDEF header information depends upon tag type */ + switch (tag->type) { + case NFC_PROTO_JEWEL: + case NFC_PROTO_MIFARE: + case NFC_PROTO_ISO15693: + if (ndef->length < 0xff) + tlv_len_size = 3; + else + tlv_len_size = 5; + + ndef_with_header = g_try_malloc0(sizeof( + struct near_ndef_message)); + if (!ndef_with_header) + goto fail; + + ndef_with_header->offset = 0; + ndef_with_header->length = ndef->length + tlv_len_size; + ndef_with_header->data = + g_try_malloc0(ndef->length + tlv_len_size); + if (!ndef_with_header->data) + goto fail; + + ndef_with_header->data[0] = TLV_NDEF; + + if (ndef->length < 0xff) { + ndef_with_header->data[1] = ndef->length; + } else { + ndef_with_header->data[1] = 0xff; + ndef_with_header->data[2] = + (uint8_t)(ndef->length >> 8); + ndef_with_header->data[3] = (uint8_t)(ndef->length); + } + + memcpy(ndef_with_header->data + tlv_len_size - 1, ndef->data, + ndef->length); + ndef_with_header->data[ndef->length + tlv_len_size - 1] = + TLV_END; + break; + + case NFC_PROTO_FELICA: + ndef_with_header = g_try_malloc0(sizeof( + struct near_ndef_message)); + if (!ndef_with_header) + goto fail; + + ndef_with_header->offset = 0; + ndef_with_header->length = ndef->length; + ndef_with_header->data = g_try_malloc0( + ndef_with_header->length); + if (!ndef_with_header->data) + goto fail; + + memcpy(ndef_with_header->data, ndef->data, ndef->length); + + break; + + case NFC_PROTO_ISO14443: + case NFC_PROTO_ISO14443_B: + ndef_with_header = g_try_malloc0(sizeof( + struct near_ndef_message)); + if (!ndef_with_header) + goto fail; + + ndef_with_header->offset = 0; + ndef_with_header->length = ndef->length + 2; + ndef_with_header->data = g_try_malloc0(ndef->length + 2); + if (!ndef_with_header->data) + goto fail; + + ndef_with_header->data[0] = (uint8_t)(ndef->length >> 8); + ndef_with_header->data[1] = (uint8_t)(ndef->length); + memcpy(ndef_with_header->data + 2, ndef->data, ndef->length); + + break; + + default: + g_free(ndef->data); + g_free(ndef); + + return __near_error_failed(msg, EOPNOTSUPP); + } + + g_free(ndef->data); + g_free(ndef); + + tag->write_ndef = ndef_with_header; + err = __near_tag_write(tag, ndef_with_header, write_cb); + if (err < 0) + return __near_error_failed(msg, -err); + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); + +fail: + dbus_message_unref(tag->write_msg); + tag->write_msg = NULL; + + return __near_error_failed(msg, ENOMEM); +} + +static const GDBusMethodTable tag_methods[] = { + { GDBUS_ASYNC_METHOD("Write", GDBUS_ARGS({"attributes", "a{sv}"}), + NULL, write_ndef) }, + { }, +}; + +static const GDBusPropertyTable tag_properties[] = { + { "Type", "s", property_get_type }, + { "Protocol", "s", property_get_protocol }, + { "ReadOnly", "b", property_get_readonly }, + { "Adapter", "o", property_get_adapter }, + + { } +}; + +void __near_tag_append_records(struct near_tag *tag, DBusMessageIter *iter) +{ + GList *list; + + for (list = tag->records; list; list = list->next) { + struct near_ndef_record *record = list->data; + char *path; + + path = __near_ndef_record_get_path(record); + if (!path) + continue; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, + &path); + } +} + +#define NFC_TAG_A (NFC_PROTO_ISO14443_MASK | NFC_PROTO_NFC_DEP_MASK | \ + NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK) +#define NFC_TAG_A_TYPE2 0x00 +#define NFC_TAG_A_TYPE4 0x01 +#define NFC_TAG_A_NFC_DEP 0x02 +#define NFC_TAG_A_TYPE4_DEP 0x03 + +#define NFC_TAG_A_SENS_RES_SSD_JEWEL 0x00 +#define NFC_TAG_A_SENS_RES_PLATCONF_JEWEL 0x0c + +#define NFC_TAG_A_SEL_PROT(sel_res) (((sel_res) & 0x60) >> 5) +#define NFC_TAG_A_SEL_CASCADE(sel_res) (((sel_res) & 0x04) >> 2) +#define NFC_TAG_A_SENS_RES_SSD(sens_res) ((sens_res) & 0x001f) +#define NFC_TAG_A_SENS_RES_PLATCONF(sens_res) (((sens_res) & 0x0f00) >> 8) + +static enum near_tag_sub_type get_tag_type2_sub_type(uint8_t sel_res) +{ + switch (sel_res) { + case 0x00: + return NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT; + case 0x08: + return NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K; + case 0x09: + return NEAR_TAG_NFC_T2_MIFARE_MINI; + case 0x18: + return NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K; + case 0x20: + return NEAR_TAG_NFC_T2_MIFARE_DESFIRE; + case 0x28: + return NEAR_TAG_NFC_T2_JCOP30; + case 0x38: + return NEAR_TAG_NFC_T2_MIFARE_4K_EMUL; + case 0x88: + return NEAR_TAG_NFC_T2_MIFARE_1K_INFINEON; + case 0x98: + return NEAR_TAG_NFC_T2_MPCOS; + } + + return NEAR_TAG_NFC_SUBTYPE_UNKNOWN; +} + +static void set_tag_type(struct near_tag *tag, + uint16_t sens_res, uint8_t sel_res) +{ + uint8_t platconf, ssd, proto; + + DBG("protocol 0x%x sens_res 0x%x sel_res 0x%x", tag->protocol, + sens_res, sel_res); + + switch (tag->protocol) { + case NFC_PROTO_JEWEL_MASK: + platconf = NFC_TAG_A_SENS_RES_PLATCONF(sens_res); + ssd = NFC_TAG_A_SENS_RES_SSD(sens_res); + + DBG("Jewel"); + + if ((ssd == NFC_TAG_A_SENS_RES_SSD_JEWEL) && + (platconf == NFC_TAG_A_SENS_RES_PLATCONF_JEWEL)) + tag->type = NFC_PROTO_JEWEL; + break; + + case NFC_PROTO_MIFARE_MASK: + case NFC_PROTO_ISO14443_MASK: + proto = NFC_TAG_A_SEL_PROT(sel_res); + + DBG("proto 0x%x", proto); + + switch (proto) { + case NFC_TAG_A_TYPE2: + tag->type = NFC_PROTO_MIFARE; + tag->sub_type = get_tag_type2_sub_type(sel_res); + break; + case NFC_TAG_A_TYPE4: + tag->type = NFC_PROTO_ISO14443; + break; + case NFC_TAG_A_TYPE4_DEP: + tag->type = NFC_PROTO_NFC_DEP; + break; + } + break; + + case NFC_PROTO_FELICA_MASK: + tag->type = NFC_PROTO_FELICA; + break; + + case NFC_PROTO_ISO14443_B_MASK: + tag->type = NFC_PROTO_ISO14443_B; + break; + + case NFC_PROTO_ISO15693_MASK: + tag->type = NFC_PROTO_ISO15693; + break; + + default: + tag->type = NFC_PROTO_MAX; + break; + } + + DBG("tag type 0x%x", tag->type); +} + +static int tag_initialize(struct near_tag *tag, + uint32_t adapter_idx, uint32_t target_idx, + uint32_t protocols, + uint16_t sens_res, uint8_t sel_res, + uint8_t *nfcid, uint8_t nfcid_len, + uint8_t iso15693_dsfid, + uint8_t iso15693_uid_len, uint8_t *iso15693_uid) +{ + DBG(""); + + tag->path = g_strdup_printf("%s/nfc%d/tag%d", NFC_PATH, + adapter_idx, target_idx); + if (!tag->path) + return -ENOMEM; + tag->adapter_idx = adapter_idx; + tag->target_idx = target_idx; + tag->protocol = protocols; + tag->next_record = 0; + tag->readonly = false; + + if (nfcid_len && nfcid_len <= NFC_MAX_NFCID1_LEN) { + tag->nfcid_len = nfcid_len; + memcpy(tag->nfcid, nfcid, nfcid_len); + } else if (iso15693_uid_len) { + tag->iso15693_dsfid = iso15693_dsfid; + memcpy(tag->iso15693_uid, iso15693_uid, iso15693_uid_len); + } + + set_tag_type(tag, sens_res, sel_res); + + return 0; +} + +struct near_tag *__near_tag_add(uint32_t adapter_idx, uint32_t target_idx, + uint32_t protocols, + uint16_t sens_res, uint8_t sel_res, + uint8_t *nfcid, uint8_t nfcid_len, + uint8_t iso15693_dsfid, + uint8_t iso15693_uid_len, uint8_t *iso15693_uid) +{ + struct near_tag *tag; + char *path; + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (tag) + return NULL; + + tag = g_try_malloc0(sizeof(struct near_tag)); + if (!tag) + return NULL; + + if (tag_initialize(tag, adapter_idx, target_idx, + protocols, + sens_res, sel_res, + nfcid, nfcid_len, + iso15693_dsfid, + iso15693_uid_len, iso15693_uid) < 0) { + g_free(tag); + return NULL; + } + + path = g_strdup(tag->path); + if (!path) { + g_free(tag); + return NULL; + } + + g_hash_table_insert(tag_hash, path, tag); + + DBG("connection %p", connection); + + g_dbus_register_interface(connection, tag->path, + NFC_TAG_INTERFACE, + tag_methods, NULL, + tag_properties, tag, NULL); + + return tag; +} + +void __near_tag_remove(struct near_tag *tag) +{ + char *path = tag->path; + + DBG("path %s", tag->path); + + g_hash_table_remove(tag_hash, path); +} + +const char *__near_tag_get_path(struct near_tag *tag) +{ + return tag->path; +} + +uint32_t __near_tag_get_type(struct near_tag *tag) +{ + return tag->type; +} + +enum near_tag_sub_type near_tag_get_subtype(uint32_t adapter_idx, + uint32_t target_idx) + +{ + struct near_tag *tag; + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + return NEAR_TAG_NFC_SUBTYPE_UNKNOWN; + + return tag->sub_type; +} + +uint8_t *near_tag_get_nfcid(uint32_t adapter_idx, uint32_t target_idx, + uint8_t *nfcid_len) +{ + struct near_tag *tag; + uint8_t *nfcid; + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + goto fail; + + nfcid = g_try_malloc0(tag->nfcid_len); + if (!nfcid) + goto fail; + + memcpy(nfcid, tag->nfcid, tag->nfcid_len); + *nfcid_len = tag->nfcid_len; + + return nfcid; + +fail: + *nfcid_len = 0; + return NULL; +} + +int near_tag_set_nfcid(uint32_t adapter_idx, uint32_t target_idx, + uint8_t *nfcid, size_t nfcid_len) +{ + struct near_tag *tag; + + DBG("NFCID len %zd", nfcid_len); + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + return -ENODEV; + + if (tag->nfcid_len > 0) + return -EALREADY; + + if (nfcid_len > NFC_MAX_NFCID1_LEN) + return -EINVAL; + + memcpy(tag->nfcid, nfcid, nfcid_len); + tag->nfcid_len = nfcid_len; + + return 0; +} + +uint8_t *near_tag_get_iso15693_dsfid(uint32_t adapter_idx, uint32_t target_idx) +{ + struct near_tag *tag; + uint8_t *iso15693_dsfid; + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + goto fail; + + iso15693_dsfid = g_try_malloc0(NFC_MAX_ISO15693_DSFID_LEN); + if (!iso15693_dsfid) + goto fail; + + memcpy(iso15693_dsfid, &tag->iso15693_dsfid, + NFC_MAX_ISO15693_DSFID_LEN); + + return iso15693_dsfid; + +fail: + return NULL; +} + +uint8_t *near_tag_get_iso15693_uid(uint32_t adapter_idx, uint32_t target_idx) +{ + struct near_tag *tag; + uint8_t *iso15693_uid; + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + goto fail; + + iso15693_uid = g_try_malloc0(NFC_MAX_ISO15693_UID_LEN); + if (!iso15693_uid) + goto fail; + + memcpy(iso15693_uid, tag->iso15693_uid, NFC_MAX_ISO15693_UID_LEN); + + return iso15693_uid; + +fail: + return NULL; +} + +int near_tag_add_data(uint32_t adapter_idx, uint32_t target_idx, + uint8_t *data, size_t data_length) +{ + struct near_tag *tag; + + tag = near_tag_get_tag(adapter_idx, target_idx); + if (!tag) + return -ENODEV; + + tag->data_length = data_length; + tag->data = g_try_malloc0(data_length); + if (!tag->data) + return -ENOMEM; + + if (data) + memcpy(tag->data, data, data_length); + + return 0; +} + +int near_tag_add_records(struct near_tag *tag, GList *records, + near_tag_io_cb cb, int status) +{ + GList *list; + struct near_ndef_record *record; + char *path; + + DBG("records %p", records); + + for (list = records; list; list = list->next) { + record = list->data; + + path = g_strdup_printf("%s/nfc%d/tag%d/record%d", + NFC_PATH, tag->adapter_idx, + tag->target_idx, tag->next_record); + + if (!path) + continue; + + __near_ndef_record_register(record, path); + + tag->next_record++; + tag->records = g_list_append(tag->records, record); + } + + __near_agent_ndef_parse_records(tag->records); + + near_dbus_property_changed_array(tag->path, + NFC_TAG_INTERFACE, "Records", + DBUS_TYPE_OBJECT_PATH, append_records, + tag); + + if (cb) + cb(tag->adapter_idx, tag->target_idx, status); + + g_list_free(records); + + return 0; +} + +void near_tag_set_ro(struct near_tag *tag, bool readonly) +{ + tag->readonly = readonly; +} + +void near_tag_set_blank(struct near_tag *tag, bool blank) +{ + tag->blank = blank; +} + +bool near_tag_get_blank(struct near_tag *tag) +{ + return tag->blank; +} + +uint8_t *near_tag_get_data(struct near_tag *tag, size_t *data_length) +{ + if (!data_length) + return NULL; + + *data_length = tag->data_length; + + return tag->data; +} + +size_t near_tag_get_data_length(struct near_tag *tag) +{ + return tag->data_length; +} + +uint32_t near_tag_get_adapter_idx(struct near_tag *tag) +{ + return tag->adapter_idx; +} + +uint32_t near_tag_get_target_idx(struct near_tag *tag) +{ + return tag->target_idx; +} + +enum near_tag_memory_layout near_tag_get_memory_layout(struct near_tag *tag) +{ + if (!tag) + return NEAR_TAG_MEMORY_UNKNOWN; + + return tag->layout; +} + +void near_tag_set_memory_layout(struct near_tag *tag, + enum near_tag_memory_layout layout) +{ + if (!tag) + return; + + tag->layout = layout; +} + +void near_tag_set_max_ndef_size(struct near_tag *tag, uint16_t size) +{ + if (!tag) + return; + + tag->t4.max_ndef_size = size; +} + +uint16_t near_tag_get_max_ndef_size(struct near_tag *tag) +{ + if (!tag) + return 0; + + return tag->t4.max_ndef_size; +} + +void near_tag_set_c_apdu_max_size(struct near_tag *tag, uint16_t size) +{ + if (!tag) + return; + + tag->t4.c_apdu_max_size = size; +} + +uint16_t near_tag_get_c_apdu_max_size(struct near_tag *tag) +{ + if (!tag) + return 0; + + return tag->t4.c_apdu_max_size; +} + +void near_tag_set_r_apdu_max_size(struct near_tag *tag, uint16_t size) +{ + if (!tag) + return; + + tag->t4.r_apdu_max_size = size; +} + +uint16_t near_tag_get_r_apdu_max_size(struct near_tag *tag) +{ + if (!tag) + return 0; + + return tag->t4.r_apdu_max_size; +} + +void near_tag_set_file_id(struct near_tag *tag, uint16_t file_id) +{ + if (!tag) + return; + + tag->t4.file_id = file_id; +} + +uint16_t near_tag_get_file_id(struct near_tag *tag) +{ + if (!tag) + return 0; + + return tag->t4.file_id; +} + +void near_tag_set_idm(struct near_tag *tag, uint8_t *idm, uint8_t len) +{ + if (!tag || len > TYPE3_IDM_LEN) + return; + + memset(tag->t3.IDm, 0, TYPE3_IDM_LEN); + memcpy(tag->t3.IDm, idm, len); +} + +uint8_t *near_tag_get_idm(struct near_tag *tag, uint8_t *len) +{ + if (!tag || !len) + return NULL; + + *len = TYPE3_IDM_LEN; + return tag->t3.IDm; +} + +void near_tag_set_attr_block(struct near_tag *tag, uint8_t *attr, uint8_t len) +{ + if (!tag || len > TYPE3_ATTR_BLOCK_SIZE) + return; + + memset(tag->t3.attr, 0, TYPE3_ATTR_BLOCK_SIZE); + memcpy(tag->t3.attr, attr, len); +} + +uint8_t *near_tag_get_attr_block(struct near_tag *tag, uint8_t *len) +{ + if (!tag || !len) + return NULL; + + *len = TYPE3_ATTR_BLOCK_SIZE; + return tag->t3.attr; +} + +void near_tag_set_ic_type(struct near_tag *tag, uint8_t ic_type) +{ + if (!tag) + return; + + tag->t3.ic_type = ic_type; +} + +uint8_t near_tag_get_ic_type(struct near_tag *tag) +{ + if (!tag) + return 0; + + return tag->t3.ic_type; +} + +uint8_t near_tag_get_blk_size(struct near_tag *tag) +{ + return tag->t5.blk_size; +} + +void near_tag_set_blk_size(struct near_tag *tag, uint8_t blk_size) +{ + tag->t5.blk_size = blk_size; +} + +uint8_t near_tag_get_num_blks(struct near_tag *tag) +{ + return tag->t5.num_blks; +} + +void near_tag_set_num_blks(struct near_tag *tag, uint8_t num_blks) +{ + tag->t5.num_blks = num_blks; +} + +static gint cmp_prio(gconstpointer a, gconstpointer b) +{ + const struct near_tag_driver *driver1 = a; + const struct near_tag_driver *driver2 = b; + + return driver2->priority - driver1->priority; +} + +int near_tag_driver_register(struct near_tag_driver *driver) +{ + DBG(""); + + if (!driver->read) + return -EINVAL; + + driver_list = g_slist_insert_sorted(driver_list, driver, cmp_prio); + + return 0; +} + +void near_tag_driver_unregister(struct near_tag_driver *driver) +{ + DBG(""); + + driver_list = g_slist_remove(driver_list, driver); +} + +int __near_tag_read(struct near_tag *tag, near_tag_io_cb cb) +{ + GSList *list; + + DBG("type 0x%x", tag->type); + + /* Stop check presence while reading */ + __near_adapter_stop_check_presence(tag->adapter_idx, tag->target_idx); + + for (list = driver_list; list; list = list->next) { + struct near_tag_driver *driver = list->data; + + DBG("driver type 0x%x", driver->type); + + if (driver->type == tag->type) + return driver->read(tag->adapter_idx, tag->target_idx, + cb); + } + + return 0; +} + +int __near_tag_write(struct near_tag *tag, + struct near_ndef_message *ndef, + near_tag_io_cb cb) +{ + GSList *list; + int err; + + DBG("type 0x%x", tag->type); + + for (list = driver_list; list; list = list->next) { + struct near_tag_driver *driver = list->data; + + DBG("driver type 0x%x", driver->type); + + if (driver->type == tag->type) { + /* Stop check presence while writing */ + __near_adapter_stop_check_presence(tag->adapter_idx, + tag->target_idx); + + if (tag->blank && driver->format) { + DBG("Blank tag detected, formatting"); + err = driver->format(tag->adapter_idx, + tag->target_idx, format_cb); + } else { + err = driver->write(tag->adapter_idx, + tag->target_idx, ndef, + cb); + } + + break; + } + } + + if (!list) + err = -EOPNOTSUPP; + + if (err < 0) + __near_adapter_start_check_presence(tag->adapter_idx, + tag->target_idx); + + return err; +} + +int __near_tag_check_presence(struct near_tag *tag, near_tag_io_cb cb) +{ + GSList *list; + + DBG("type 0x%x", tag->type); + + for (list = driver_list; list; list = list->next) { + struct near_tag_driver *driver = list->data; + + DBG("driver type 0x%x", driver->type); + + if (driver->type == tag->type) { + if (!driver->check_presence) + continue; + + return driver->check_presence(tag->adapter_idx, tag->target_idx, cb); + } + } + + return -EOPNOTSUPP; +} + +static void free_tag(gpointer data) +{ + struct near_tag *tag = data; + + DBG("tag %p", tag); + + near_ndef_records_free(tag->records); + + g_dbus_unregister_interface(connection, tag->path, + NFC_TAG_INTERFACE); + + g_free(tag->path); + g_free(tag->data); + g_free(tag); +} + +int __near_tag_init(void) +{ + DBG(""); + + connection = near_dbus_get_connection(); + + tag_hash = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, free_tag); + + return 0; +} + +void __near_tag_cleanup(void) +{ + DBG(""); + + g_hash_table_destroy(tag_hash); + tag_hash = NULL; +}
diff --git a/neard/src/tlv.c b/neard/src/tlv.c new file mode 100644 index 0000000..b6829f2 --- /dev/null +++ b/neard/src/tlv.c
@@ -0,0 +1,115 @@ +/* + * + * neard - Near Field Communication manager + * + * Copyright (C) 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "near.h" + +uint16_t near_tlv_length(uint8_t *tlv) +{ + uint16_t length; + + if (tlv[0] == TLV_NULL || tlv[0] == TLV_END) + length = 0; + else if (tlv[1] == 0xff) + length = near_get_be16(tlv + 2); + else + length = tlv[1]; + + return length; +} + +uint8_t *near_tlv_next(uint8_t *tlv) +{ + uint16_t length; + uint8_t l_length; + + length = near_tlv_length(tlv); + if (length > 0xfe) + l_length = 3; + else if (length == 0) + l_length = 0; + else + l_length = 1; + + /* T (1 byte) + L (1 or 3 bytes) + V */ + return tlv + 1 + l_length + length; +} + +uint8_t *near_tlv_data(uint8_t *tlv) +{ + uint16_t length; + uint8_t l_length; + + length = near_tlv_length(tlv); + if (length > 0xfe) + l_length = 3; + else if (length == 0) + l_length = 0; + else + l_length = 1; + + /* T (1 byte) + L (1 or 3 bytes) */ + return tlv + 1 + l_length; +} + +GList *near_tlv_parse(uint8_t *tlv, size_t tlv_length) +{ + GList *records; + uint8_t *data, t; + + DBG(""); + + records = NULL; + data = tlv; + + while (1) { + t = tlv[0]; + + DBG("tlv 0x%x", tlv[0]); + + switch (t) { + case TLV_NDEF: + DBG("NDEF found %d bytes long", near_tlv_length(tlv)); + + records = near_ndef_parse_msg(near_tlv_data(tlv), + near_tlv_length(tlv), NULL); + + break; + case TLV_END: + break; + } + + if (t == TLV_END) + break; + + tlv = near_tlv_next(tlv); + + if (tlv - data >= (uint16_t) tlv_length) + break; + } + + DBG("Done"); + + return records; +}
diff --git a/neard/test-driver b/neard/test-driver new file mode 100755 index 0000000..d306056 --- /dev/null +++ b/neard/test-driver
@@ -0,0 +1,139 @@ +#! /bin/sh +# test-driver - basic testsuite driver script. + +scriptversion=2013-07-13.22; # UTC + +# Copyright (C) 2011-2013 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 <http://www.gnu.org/licenses/>. + +# 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 <bug-automake@gnu.org> or send patches to +# <automake-patches@gnu.org>. + +# Make unconditional expansion of undefined variables an error. This +# helps a lot in preventing typo-related bugs. +set -u + +usage_error () +{ + echo "$0: $*" >&2 + print_usage >&2 + exit 2 +} + +print_usage () +{ + cat <<END +Usage: + test-driver --test-name=NAME --log-file=PATH --trs-file=PATH + [--expect-failure={yes|no}] [--color-tests={yes|no}] + [--enable-hard-errors={yes|no}] [--] + TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS] +The '--test-name', '--log-file' and '--trs-file' options are mandatory. +END +} + +test_name= # Used for reporting. +log_file= # Where to save the output of the test script. +trs_file= # Where to save the metadata of the test run. +expect_failure=no +color_tests=no +enable_hard_errors=yes +while test $# -gt 0; do + case $1 in + --help) print_usage; exit $?;; + --version) echo "test-driver $scriptversion"; exit $?;; + --test-name) test_name=$2; shift;; + --log-file) log_file=$2; shift;; + --trs-file) trs_file=$2; shift;; + --color-tests) color_tests=$2; shift;; + --expect-failure) expect_failure=$2; shift;; + --enable-hard-errors) enable_hard_errors=$2; shift;; + --) shift; break;; + -*) usage_error "invalid option: '$1'";; + *) break;; + esac + shift +done + +missing_opts= +test x"$test_name" = x && missing_opts="$missing_opts --test-name" +test x"$log_file" = x && missing_opts="$missing_opts --log-file" +test x"$trs_file" = x && missing_opts="$missing_opts --trs-file" +if test x"$missing_opts" != x; then + usage_error "the following mandatory options are missing:$missing_opts" +fi + +if test $# -eq 0; then + usage_error "missing argument" +fi + +if test $color_tests = yes; then + # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'. + red='[0;31m' # Red. + grn='[0;32m' # Green. + lgn='[1;32m' # Light green. + blu='[1;34m' # Blue. + mgn='[0;35m' # Magenta. + std='[m' # No color. +else + red= grn= lgn= blu= mgn= std= +fi + +do_exit='rm -f $log_file $trs_file; (exit $st); exit $st' +trap "st=129; $do_exit" 1 +trap "st=130; $do_exit" 2 +trap "st=141; $do_exit" 13 +trap "st=143; $do_exit" 15 + +# Test script is run here. +"$@" >$log_file 2>&1 +estatus=$? +if test $enable_hard_errors = no && test $estatus -eq 99; then + estatus=1 +fi + +case $estatus:$expect_failure in + 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; + 0:*) col=$grn res=PASS recheck=no gcopy=no;; + 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; + 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; + *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; + *:*) col=$red res=FAIL recheck=yes gcopy=yes;; +esac + +# Report outcome to console. +echo "${col}${res}${std}: $test_name" + +# Register the test result, and other relevant metadata. +echo ":test-result: $res" > $trs_file +echo ":global-test-result: $res" >> $trs_file +echo ":recheck: $recheck" >> $trs_file +echo ":copy-in-global-log: $gcopy" >> $trs_file + +# 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:
diff --git a/neard/test/bt-handover b/neard/test/bt-handover new file mode 100755 index 0000000..42d66bf --- /dev/null +++ b/neard/test/bt-handover
@@ -0,0 +1,131 @@ +#!/usr/bin/python + +import os +import sys +import gobject + +import dbus +import dbus.mainloop.glib +from optparse import OptionParser +import neardutils + +from dbus.lowlevel import MethodCallMessage, HANDLER_RESULT_NOT_YET_HANDLED + +mainloop = gobject.MainLoop() + +def device_added(path, interfaces): + for iface, props in interfaces.iteritems(): + if "org.neard.Device" in interfaces: + print("Pairing with %s" % (path)) + device = dbus.Interface(bus.get_object("org.neard", path), + "org.neard.Device") + device.Push(({ "Type" : "Handover", "Carrier" : "bluetooth"})) + break + +def device_removed(path, interfaces): + for iface in interfaces: + if "org.neard.Device" in interfaces: + print("Lost device %s" % (path)) + mainloop.quit() + break + +def remove_paired_devices(bt_adapter): + manager = dbus.Interface(bus.get_object("org.bluez", "/"), + "org.freedesktop.DBus.ObjectManager") + objects = manager.GetManagedObjects() + + all_adapters = (path for path, interfaces in objects.iteritems() if + "org.bluez.Adapter1" in interfaces.keys() + and path.endswith(bt_adapter)) + + bluez_adapter = None + for adapter in sorted(all_adapters): + bluez_adapter = dbus.Interface(bus.get_object("org.bluez", + adapter), + "org.bluez.Adapter1") + break + + if(bluez_adapter is None): + print("Bluetooth adapter %s could not be found" % bluez_adapter) + exit() + + adapter_path = bluez_adapter.object_path + print("Using %s" % adapter_path) + + adapter_props = dbus.Interface(bus.get_object("org.bluez", adapter_path), + "org.freedesktop.DBus.Properties") + + powered = adapter_props.Get("org.bluez.Adapter1", "Powered") + if (powered == dbus.Boolean(0)): + print("Bluetooth adapter %s is not powered" % adapter_path ) + exit() + + all_devices = (path for path, interfaces in objects.iteritems() if + ("org.bluez.Device1" in interfaces.keys() + and path.startswith(bluez_adapter.object_path))) + + for device in all_devices: + print("Removing %s" % (device)) + bluez_adapter.RemoveDevice(device) + +def remove_paired_devices_bluez4(): + bluez_manager = dbus.Interface(bus.get_object("org.bluez", "/"), + "org.bluez.Manager") + + bluez_adapter_path = bluez_manager.DefaultAdapter() + bluez_adapter = dbus.Interface(bus.get_object("org.bluez", + bluez_adapter_path), + "org.bluez.Adapter") + + print("Using %s" % bluez_adapter.object_path) + + for bluez_path in bluez_adapter.ListDevices(): + print("Removing %s" % (bluez_path)) + bluez_adapter.RemoveDevice(bluez_path) + +if __name__ == '__main__': + parser = OptionParser() + parser.add_option("", "--bluez4", action="store_true", + dest="use_bluez4", + help="Use BlueZ 4 to remove paired devices.") + parser.add_option("-a", "--adapter", metavar="BT_ADAPTER", + dest="bt_adapter", default="", + help="The bluetooth adapter that is used by " + "the bluetooth stack. This options is " + "ignored when using BlueZ 4, instead " + "the default adapter is used.") + (options, args) = parser.parse_args() + + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SystemBus() + + adapter_path = neardutils.find_adapter().object_path + print("Adapter path %s" % (adapter_path)) + adapter = dbus.Interface(bus.get_object("org.neard", adapter_path), + "org.neard.Adapter") + + adapter_props = dbus.Interface(bus.get_object("org.neard", adapter_path), + "org.freedesktop.DBus.Properties") + powered = adapter_props.Get("org.neard.Adapter", "Powered") + if (powered == dbus.Boolean(0)): + adapter_props.Set("org.neard.Adapter", "Powered", dbus.Boolean(1)) + + if (options.use_bluez4): + remove_paired_devices_bluez4() + else: + remove_paired_devices(options.bt_adapter) + + polling = adapter_props.Get("org.neard.Adapter", "Polling") + if (polling == dbus.Boolean(0)): + adapter.StartPollLoop("Initiator") + + bus.add_signal_receiver(device_added, bus_name="org.neard", + dbus_interface="org.freedesktop.DBus.ObjectManager", + signal_name="InterfacesAdded") + + bus.add_signal_receiver(device_removed, bus_name="org.neard", + dbus_interface="org.freedesktop.DBus.ObjectManager", + signal_name="InterfacesRemoved") + + mainloop.run()
diff --git a/neard/test/handover-agent b/neard/test/handover-agent new file mode 100755 index 0000000..7f2ac23 --- /dev/null +++ b/neard/test/handover-agent
@@ -0,0 +1,140 @@ +#!/usr/bin/python + +import gobject + +import dbus +import dbus.service +import dbus.mainloop.glib +from optparse import OptionParser + +eir_test_data = [0x16,0x00\ + ,0x01,0x02,0x03,0x04,0x05,0x06\ + ,0x08,0x09,0x41,0x72,0x72,0x61,0x6b,0x69,0x73\ + ,0x04,0x0d,0x6e,0x01,0x00] + +wsc_test_data = [0x10,0x4A,0x00,0x01,0x10\ + ,0x10,0x45,0x00,0x08\ + ,0x74,0x65,0x73,0x74,0x73,0x73,0x69,0x64\ + ,0x10,0x27,0x00,0x06\ + ,0x62,0x6C,0x61,0x62,0x6C,0x61] + +power_state = None + +def print_fields(fields): + if 'EIR' in fields: + s = ' '.join('{:#02x}'.format(i) for i in fields['EIR']) + print ' EIR: %s' % s + + if 'nokia.com:bt' in fields: + s = ' '.join('{:#02x}'.format(i) for i in fields['nokia.com:bt']) + print ' nokia.com:bt: %s' % s + + if 'State' in fields: + print ' State: %s' % fields['State'] + + if 'WSC' in fields: + s = ' '.join('{:#02x}'.format(i) for i in fields['WSC']) + print ' WSC: %s' % s + +class BTHOAgent(dbus.service.Object): + + @dbus.service.method('org.neard.HandoverAgent', + in_signature='', + out_signature='') + def Release(self): + print 'Release' + mainloop.quit() + + @dbus.service.method('org.neard.HandoverAgent', + in_signature='a{sv}', + out_signature='') + def PushOOB(self, fields): + print 'PushOOB' + print_fields(fields) + + @dbus.service.method('org.neard.HandoverAgent', + in_signature='a{sv}', + out_signature='a{sv}') + + def RequestOOB(self, fields): + print 'RequestOOB' + print_fields(fields) + + print ' Replying with' + s = ' '.join('{:#02x}'.format(i) for i in eir_test_data) + print ' EIR: %s' % s + + if power_state != 'unknown': + print ' State: %s' % power_state + return {'EIR' : eir_test_data, 'State' : power_state} + else: + return {'EIR' : eir_test_data} + +class WiFiHOAgent(dbus.service.Object): + + @dbus.service.method('org.neard.HandoverAgent', + in_signature='', + out_signature='') + def Release(self): + print 'Release' + mainloop.quit() + + @dbus.service.method('org.neard.HandoverAgent', + in_signature='a{sv}', + out_signature='') + def PushOOB(self, fields): + print 'PushOOB' + print_fields(fields) + + @dbus.service.method('org.neard.HandoverAgent', + in_signature='a{sv}', + out_signature='a{sv}') + + def RequestOOB(self, fields): + print 'RequestOOB' + print_fields(fields) + + print ' Replying with' + s = ' '.join('{:#02x}'.format(i) for i in wsc_test_data) + print ' WSC: %s' % s + + if power_state != 'unknown': + print ' State: %s' % power_state + return {'WSC' : wsc_test_data, 'State' : power_state} + else: + return {'WSC' : wsc_test_data} + +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SystemBus() + + parser = OptionParser() + parser.add_option("-s", "--power-state", action="store", type="string", + dest="power_state", default="active", + help="active inactive activating unknown") + (options, args) = parser.parse_args() + + power_state = options.power_state + + obj = bus.get_object("org.neard", "/org/neard"); + manager = dbus.Interface(obj, "org.neard.AgentManager") + + btpath = '/test/handover/bt/agent' + btcarrier = 'bluetooth' + btobject = BTHOAgent(bus, btpath) + + wifipath = '/test/handover/wifi/agent' + wificarrier = 'wifi' + wifiobject = WiFiHOAgent(bus, wifipath) + + manager.RegisterHandoverAgent(btpath, btcarrier) + manager.RegisterHandoverAgent(wifipath, wificarrier) + + mainloop = gobject.MainLoop() + + try: + mainloop.run() + except (KeyboardInterrupt): + manager.UnregisterHandoverAgent(btpath, btcarrier) + manager.UnregisterHandoverAgent(wifipath, wificarrier)
diff --git a/neard/test/monitor-near b/neard/test/monitor-near new file mode 100755 index 0000000..f3ad021 --- /dev/null +++ b/neard/test/monitor-near
@@ -0,0 +1,46 @@ +#!/usr/bin/python + +from __future__ import absolute_import, print_function, unicode_literals + +import gobject + +import dbus +import dbus.mainloop.glib + +def property_changed(interface, changed, invalidated, path): + iface = interface[interface.rfind(".") + 1:] + for name, value in changed.iteritems(): + val = str(value) + print("{%s.PropertyChanged} [%s] %s = %s" % (iface, path, name, + val)) + +def interfaces_added(path, interfaces): + for iface, props in interfaces.iteritems(): + print("{Added %s} [%s]" % (iface, path)) + for name, value in props.iteritems(): + print(" %s = %s" % (name, value)) + +def interfaces_removed(path, interfaces): + for iface in interfaces: + print("{Removed %s} [%s]" % (iface, path)) + +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SystemBus() + + bus.add_signal_receiver(property_changed, bus_name="org.neard", + dbus_interface="org.freedesktop.DBus.Properties", + signal_name="PropertiesChanged", + path_keyword="path") + + bus.add_signal_receiver(interfaces_added, bus_name="org.neard", + dbus_interface="org.freedesktop.DBus.ObjectManager", + signal_name="InterfacesAdded") + + bus.add_signal_receiver(interfaces_removed, bus_name="org.neard", + dbus_interface="org.freedesktop.DBus.ObjectManager", + signal_name="InterfacesRemoved") + + mainloop = gobject.MainLoop() + mainloop.run() \ No newline at end of file
diff --git a/neard/test/ndef-agent b/neard/test/ndef-agent new file mode 100755 index 0000000..1cfeb03 --- /dev/null +++ b/neard/test/ndef-agent
@@ -0,0 +1,78 @@ +#!/usr/bin/python + +import gobject + +import dbus +import dbus.service +import dbus.mainloop.glib +import sys + +class NDEFAgent(dbus.service.Object): + + @dbus.service.method("org.neard.NDEFAgent", + in_signature='', out_signature='') + def Release(self): + print "Release" + mainloop.quit() + + @dbus.service.method("org.neard.NDEFAgent", + in_signature='a{sv}', + out_signature='') + def GetNDEF(self, fields): + print "GetNDEF" + + if fields.has_key("Record"): + print "Record path %s" % (fields["Record"]) + + if fields.has_key("Payload"): + val = "[" + for i in fields["Payload"]: + val += " 0x%x" % i + val += " ]" + print "Record payload %s" % val + + if fields.has_key("NDEF"): + val = "[" + for i in fields["NDEF"]: + val += " 0x%x" % i + val += " ]" + print "Complete NDEF %s" % val + + return + + @dbus.service.method("org.neard.NDEFAgent", + in_signature='', out_signature='') + def Cancel(self): + print "Cancel" + +def print_usage(): + print "Usage:" + print "%s Type=<record type>" % (sys.argv[0]) + print "Help: %s help" % (sys.argv[0]) + sys.exit(1) + +if __name__ == '__main__': + if len(sys.argv) != 2: + print_usage() + + if len(sys.argv) == 2 and sys.argv[1] == "help": + print_usage() + + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SystemBus() + obj = bus.get_object("org.neard", "/org/neard"); + manager = dbus.Interface(obj, "org.neard.AgentManager") + + path = "/test/ndef/agent" + object = NDEFAgent(bus, path) + rec_type = sys.argv[1].replace("Type=", "", 1) + + manager.RegisterNDEFAgent(path, rec_type) + + mainloop = gobject.MainLoop() + + try: + mainloop.run() + except (KeyboardInterrupt): + manager.UnregisterNDEFAgent(path, rec_type)
diff --git a/neard/test/neard-ui.py b/neard/test/neard-ui.py new file mode 100755 index 0000000..1113ca8 --- /dev/null +++ b/neard/test/neard-ui.py
@@ -0,0 +1,586 @@ +#!/usr/bin/env python + +import pdb +import sys + +import gobject +import gtk + +import dbus +import dbus.service +import dbus.mainloop.glib + +import traceback + +##================================================================= +class Neard: + + #signal handler #1 for Manager + def manager_Added(self, name): + print (" Added %s") % name + self.manager_getDetails() + + #signal handler #2 for Manager + def manager_Removed(self, name): + print (" Removed %s") % name + if self.adapters_remove is not None: + self.adapter_update(name) + return + + #connect to the manager in order to be notified on + #add/remove adapter + def manager_Connect(self): + try: + manager_obj = self.systemBus.get_object('org.neard', "/") + # Add 2 handlers to follow Adapters + manager_obj.connect_to_signal('AdapterAdded', + self.manager_Added, + 'org.neard.Manager') + manager_obj.connect_to_signal('AdapterRemoved', + self.manager_Removed, + 'org.neard.Manager') + self.iface_manager = dbus.Interface(manager_obj, 'org.neard.Manager') + + except: + print ("Can't connect to org.neard.Manager"); + self.iface_manager = None + #Retrieve the manager informations + self.manager_getDetails() + + def manager_getDetails(self): + #No iface_manager means adapter removed + if self.iface_manager is None: + if self.adapters_remove is not None: + self.adapters_remove() + return + #Need to update adapter's details + self.adapter_updateDetails(self.iface_manager.GetProperties()) + + def adapter_PropertyChanged(self, prop, value, adapt_path = None): + print("Prop changed: %s") % prop + adapt_properties = {} + adapt_properties[prop] = value + if prop == "Tags": + self.tag_updateDetails(adapt_properties) + else: + self.adapter_update(adapt_path, adapt_properties) + + #Update the records UI + def record_updateDetails(self, tag_properties): + for record_path in tag_properties["Records"]: + print ("REC %s ") % record_path + record_obj = self.systemBus.get_object('org.neard', + record_path) + record_iface = dbus.Interface(record_obj,'org.neard.Record') + record_properties = record_iface.GetProperties() + + self.recordregistered[record_path] = True + + # call UI update + self.records_update(record_path, record_properties) + + #Update the tags UI + def tag_updateDetails(self, adapt_properties): + if adapt_properties["Tags"]: + for tag_path in adapt_properties["Tags"]: + print ("TAG %s ") % tag_path + tag_obj = self.systemBus.get_object('org.neard', tag_path) + + tag_iface = dbus.Interface(tag_obj,'org.neard.Tag') + tag_properties = tag_iface.GetProperties() + + self.tagregistered[tag_path] = True + # call UI update + self.tags_update(tag_path, tag_properties) + #Process the records + self.record_updateDetails(tag_properties) + else: + print ("remove tags and records") + self.tags_update() + self.records_update() + + + #Something changed, must update the UI + def adapter_updateDetails(self, properties): + if self.adapter_update is not None and "Adapters" in properties: + for adapt_path in properties["Adapters"]: + if adapt_path in self.adaptregistered: + print (" already registered %s") % adapt_path + else: + #Get valuable informations from the object + adapter_obj = self.systemBus.get_object('org.neard', + adapt_path) + adapter_obj.connect_to_signal('PropertyChanged', + self.adapter_PropertyChanged, + 'org.neard.Adapter', + path_keyword='adapt_path') + + adapt_iface = dbus.Interface(adapter_obj,'org.neard.Adapter') + adapt_properties = adapt_iface.GetProperties() + + self.adaptregistered[adapt_path] = True + + #Update display info + self.adapter_update(adapt_path, adapt_properties) + + #udpate UI for tags + self.tag_updateDetails(adapt_properties) + + + #Search DBUS to find any neard instance + def neardNameOwnerChanged(self, proxy): + if proxy: + print("Neard is connected to System bus") + self.manager_Connect() + else: + print("Neard is disconnected from System bus") + self.iface_manager = None + self.adaptregistered = {} + self.manager_getDetails() + + #Main init function + def __init__(self, adapter_update = None, adapters_remove = None, + tags_update = None, records_update = None): + self.test = False + self.adapter_update = adapter_update + self.adapters_remove = adapters_remove + self.tags_update = tags_update + self.records_update = records_update + + self.adaptregistered = {} + self.tagregistered = {} + self.recordregistered = {} + + self.systemBus = dbus.SystemBus() + + #Prepare the first handler + self.systemBus.watch_name_owner('org.neard', + self.neardNameOwnerChanged) + +##================================================================= +class NeardUI(Neard): + + # return the current selection + def adapters_actionToggle(self, i, col): + if i: + return self.adapters_list.get_value(i, col) + return True + + # Action: activate or not the polling mode + def adapter_pollingToggled(self, poolingRendererToggle, path, user): + if path: + i = self.adapters_list.get_iter(path) + objpath = self.adapters_list.get_value(i, 0) + adapter_obj = self.systemBus.get_object('org.neard', objpath) + adapt_iface = dbus.Interface(adapter_obj,'org.neard.Adapter') + + if self.adapters_actionToggle(i, 3): + print ("Stop Polling %s") % objpath + adapt_iface.StopPollLoop() + else: + print ("Start Polling %s") % objpath + adapt_iface.StartPollLoop("Initiator") + + + #------------------------------ + #Set the field values + def adapters_setUIList(self, adapt_properties, i, col, name, path = None): + if name in adapt_properties: + value = adapt_properties[name] + + if name == "Tags": + value = "{" + for tgts in adapt_properties[name]: + #For each tag, add it to the tag lbox: + #Trim path.... + short_tgt = tgts[len(path)+1:] + + if value == "{": + value = "{" + short_tgt + else: + value = value + "," + short_tgt + value = value + "}" + + if name == "Protocols": + value = None + for protos in adapt_properties[name]: + if value is None: + value = protos + else: + value = value + " " + protos + + if value is not None: + self.adapters_list.set_value(i, col, value) + print (" property %s, value %s") % (name, value) + + # Clear one or all the adapters present in list + def adapter_RemoveUI(self): + self.adapters_list.clear() + + #Add, Update or delete a list entry + def adapter_UpdateUI(self, path = None, adapt_properties = None): + i = self.adapters_list.get_iter_first() + while i is not None: + if self.adapters_list.get_value(i, 0) == path: + break + i = self.adapters_list.iter_next(i) + + if adapt_properties is None: + if i: + print ("Delete adapter %s") % path + self.adapters_list.remove(i) + else: + print ("Already deleted adapter %s") % path + return + + if i is None: + i = self.adapters_list.append() + self.adapters_list.set_value(i, 0, path) + print ("Add adapter %s") % (path) + else: + print ("Update adapter %s") % (path) + + + self.adapters_setUIList(adapt_properties, i, 2, "Powered") + self.adapters_setUIList(adapt_properties, i, 3, "Polling") + self.adapters_setUIList(adapt_properties, i, 4, "Protocols") + self.adapters_setUIList(adapt_properties, i, 5, "Tags", path) + + #-------------------------------------------------- + def tags_setUIList(self, tag_properties, i, col, name): + if name in tag_properties: + value = tag_properties[name] + + if name == "Records": + value = None + for tags in tag_properties[name]: + #For each tag, add it to the tag lbox: + if value is None: + value = tags + else: + value = value + "-" + tags + + if name == "Type": + value = None + for tags in tag_properties[name]: + #For each tag, add it to the tag lbox: + if value is None: + value = tags + else: + value = value + "-" + tags + + if value is not None: + self.tags_list.set_value(i, col, value) + print (" property %s, value %s") % (name, value) + + #Add, Update or delete a list entry + def tag_UpdateUI(self, path = None, tag_properties = None): + print("Tag Update %s") % path + i = self.tags_list.get_iter_first() + while i is not None: + if self.tags_list.get_value(i, 0) == path: + break + i = self.tags_list.iter_next(i) + + #Delete mode: Remove all + if tag_properties is None: + i = self.tags_list.get_iter_first() + while i is not None: + path_name = self.tags_list.get_value(i, 0) + print ("Deleted tag %s") % path_name + self.tags_list.remove(i) + if self.tags_list.iter_is_valid(i): + i = self.tags_list.iter_next(i) + else: + i = None + return + + if i is None: + i = self.tags_list.append() + self.tags_list.set_value(i, 0, path) + print ("Add tag %s") % (path) + else: + print ("Update tag %s") % (path) + self.tags_setUIList(tag_properties, i, 2, "ReadOnly") + self.tags_setUIList(tag_properties, i, 3, "Type") + self.tags_setUIList(tag_properties, i, 4, "Records") + + #-------------------------------------------------- + def records_setUIList(self, record_properties, i, col, name): + if name in record_properties: + value = record_properties[name] + else: + value = "" + for rec_data in record_properties: + if rec_data != "Type": + if value != "": + value = value + "\n" + value = value + rec_data + " : " +record_properties[rec_data] + + if value is not None: + self.records_list.set_value(i, col, value) + print (" property %s, value %s") % (name, value) + + #Add, Update or delete a list entry + def record_UpdateUI(self, path = None, record_properties = None): + print("Record Update %s") % path + i = self.records_list.get_iter_first() + while i is not None: + if self.records_list.get_value(i, 0) == path: + break + i = self.records_list.iter_next(i) + + #Delete mode: Remove all records + if record_properties is None: + i = self.records_list.get_iter_first() + while i is not None: + path_name = self.records_list.get_value(i, 0) + print ("Delete record %s") % path_name + self.records_list.remove(i) + if self.records_list.iter_is_valid(i): + i = self.records_list.iter_next(i) + else: + i = None + return + + if i is None: + i = self.records_list.append() + self.records_list.set_value(i, 0, path) + print ("Add record %s") % (path) + else: + print ("Update record %s") % (path) + + self.records_setUIList(record_properties, i, 2, "Type") + self.records_setUIList(record_properties, i, 3, "Data") + + + def tag_RemoveUI(self): + printf("Tag Remove") + + #Adapter selected on lbox + def on_adapter_sel_changed(self, selection = None): + model, iter = selection.get_selected() + if iter: + value = self.adapters_list.get_value(iter, 0) + print ("value %s") % value + value = self.adapters_list.get_value(iter, 5) + print ("tag: %s") % value + + + #----------------------------------------------------- + # Prepare TreeView for Adapters + def createAdaptersWidgets(self, adaptlist): + + #treeview adapters + tv_adapters = gtk.TreeView(adaptlist) + + column = gtk.TreeViewColumn("Path", gtk.CellRendererText(), text=0) + tv_adapters.append_column(column) + + toggle = gtk.CellRendererToggle() + column = gtk.TreeViewColumn("Powered", toggle, active=2) + tv_adapters.append_column(column) + + toggle = gtk.CellRendererToggle() + column = gtk.TreeViewColumn("Polling", toggle, active=3) + toggle.connect('toggled', self.adapter_pollingToggled, None) + tv_adapters.append_column(column) + + column = gtk.TreeViewColumn("Protocols",gtk.CellRendererText(), text=4) + tv_adapters.append_column(column) + + column = gtk.TreeViewColumn("Tags", gtk.CellRendererText(), text=5) + tv_adapters.append_column(column) + + tv_adapters.get_selection().connect("changed", + self.on_adapter_sel_changed) + + return tv_adapters; + + # Prepare TreeView for Tags + def createTagsWidgets(self, tags_list): + + + tv_tags = gtk.TreeView(tags_list) + + column = gtk.TreeViewColumn("Path", gtk.CellRendererText(), text=0) + tv_tags.append_column(column) + toggle = gtk.CellRendererToggle() + column = gtk.TreeViewColumn("ReadOnly", toggle, active=2) + tv_tags.append_column(column) + + column = gtk.TreeViewColumn("Type", gtk.CellRendererText(), text=3) + tv_tags.append_column(column) + + column = gtk.TreeViewColumn("Record", gtk.CellRendererText(), text=4) + tv_tags.append_column(column) + + return tv_tags;# + + # Prepare TreeView for Records + def createRecordsWidgets(self, records_list): + #treeview Records + tv_records = gtk.TreeView(records_list) + tv_records.connect("row-activated", self.on_record_activated) + + column = gtk.TreeViewColumn("Path", gtk.CellRendererText(), text=0) + tv_records.append_column(column) + + column = gtk.TreeViewColumn("Type", gtk.CellRendererText(), text=2) + tv_records.append_column(column) + + column = gtk.TreeViewColumn("Data", gtk.CellRendererText(), text=3) + tv_records.append_column(column) + return tv_records; + + def on_record_activated(self, widget, row, col): + model = widget.get_model() + recordUI = RecordUI(self.neardDialog, model[row][0], model[row][2]) + recordUI.show() + + def dlg_onResponse(self, dialog, response): + self.neardDialog.destroy() + self.neardDialog = None + if self.response_callback is not None: + self.response_callback(response) + + #------------------------------ + #Prepare the dialog + def createDialog(self, title = None): + if self.title is not None: + title = self.title + dialog = gtk.Dialog(title, None, + gtk.DIALOG_MODAL | + gtk.DIALOG_DESTROY_WITH_PARENT, + (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) + dialog.set_property("resizable", True) + dialog.set_default_size(800, 300) + + notebook = gtk.Notebook() + dialog.child.add(notebook) + + # Create the first tab...an adapters's list + scrolledwindow = gtk.ScrolledWindow() + widget = self.createAdaptersWidgets(self.adapters_list) + scrolledwindow.add(widget) +# notebook.append_page(widget, gtk.Label("Adapters")) + notebook.append_page(scrolledwindow, gtk.Label("Adapters")) + + scrolledwindow = gtk.ScrolledWindow() + widget = self.createTagsWidgets(self.tags_list) + scrolledwindow.add(widget) + + notebook.append_page(scrolledwindow, gtk.Label("Tags")) + + scrolledwindow = gtk.ScrolledWindow() + widget = self.createRecordsWidgets(self.records_list) + scrolledwindow.add(widget) + notebook.append_page(scrolledwindow, gtk.Label("Records")) + + dialog.connect('response', self.dlg_onResponse) +# dialog.vbox.pack_end(vbox, True, True, 0) + return dialog + + def show(self): + if self.neardDialog is None: + self.neardDialog = self.createDialog() + self.neardDialog.show_all() + + def __init__(self, title = None, response_callback = None): + self.title = title + self.response_callback = response_callback + self.neardDialog = None + + self.adapters_list = gtk.ListStore(gobject.TYPE_STRING, # path =0 + gobject.TYPE_STRING, # Name = 1 + gobject.TYPE_BOOLEAN, # powered = 2 + gobject.TYPE_BOOLEAN, # polling = 3 + gobject.TYPE_STRING, # protocols = 4 + gobject.TYPE_STRING) # tags = 5 + + self.tags_list = gtk.ListStore(gobject.TYPE_STRING, # path =0 + gobject.TYPE_STRING, # Name = 1 + gobject.TYPE_BOOLEAN, # Read Only 2 + gobject.TYPE_STRING, # Type = 3 + gobject.TYPE_STRING) # Record = 4 + + self.records_list = gtk.ListStore(gobject.TYPE_STRING, # path =0 + gobject.TYPE_STRING, # Name = 1 + gobject.TYPE_STRING, # Type = 2 + gobject.TYPE_STRING) # content = 3 + + Neard.__init__(self, self.adapter_UpdateUI, self.adapter_RemoveUI + , self.tag_UpdateUI, self.record_UpdateUI) + +class RecordUI(): + def wr_onResponse(self, dialog, response): + if response != gtk.RESPONSE_ACCEPT: + return + content = self.content_entry.get_text() + type_name = self.type_combo.get_active_text() + bus = dbus.SystemBus() + record_path = self.path + tag_path = record_path[:record_path.rfind("/")] + tag = dbus.Interface(bus.get_object("org.neard", tag_path), "org.neard.Tag") + if type_name in ["Text"]: + content1 = content.split() + tag.Write({"Type" : type_name, + "Encoding" : content1[0], + "Language" : content1[1], + "Representation" : ' '.join(content1[2:])}) + else: + tag.Write({"Type" : type_name, + "URI" : content}) + dialog.destroy() + + def __init__(self, parent = None, path = None, type_name = None): + self.path = path + type_combo = gtk.combo_box_new_text() + type_combo.append_text('Text') + type_combo.append_text('URI') + type_combo.append_text('SmartPoster') + if type_name == 'Text': + type_combo.set_active(0) + elif type_name == 'URI': + type_combo.set_active(1) + elif type_name == 'SmartPoster': + type_combo.set_active(2) + fixed = gtk.Fixed() + content_entry = gtk.Entry() + fixed.put(type_combo, 20, 40) + fixed.put(content_entry, 150, 40) + type_label = gtk.Label("Type") + content_label = gtk.Label("Content") + fixed.put(type_label, 20, 15) + fixed.put(content_label, 150, 15) + + record_dialog = gtk.Dialog("Write Record", parent, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, + (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) + self.record_dialog = record_dialog + record_dialog.set_default_size(280, 120) + record_dialog.set_position(gtk.WIN_POS_CENTER) + record_dialog.connect('response', self.wr_onResponse) + hbox = record_dialog.get_content_area() + hbox.pack_start(fixed) + self.type_combo = type_combo + self.content_entry = content_entry + fixed.show_all() + + def show(self): + self.record_dialog.run() + self.record_dialog.destroy() + +##================================================================= +if __name__ == "__main__": + + def endmainloop(response): + mainloop.quit() + + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + mainloop = gobject.MainLoop() + + m = NeardUI("Neard", endmainloop) + m.show() + + mainloop.run()
diff --git a/neard/test/neardutils.py b/neard/test/neardutils.py new file mode 100644 index 0000000..903e59e --- /dev/null +++ b/neard/test/neardutils.py
@@ -0,0 +1,96 @@ +import dbus + +SERVICE_NAME = "org.neard" +ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter" +DEVICE_INTERFACE = SERVICE_NAME + ".Device" +TAG_INTERFACE = SERVICE_NAME + ".Tag" +RECORD_INTERFACE = SERVICE_NAME + ".Record" + +def get_managed_objects(): + bus = dbus.SystemBus() + manager = dbus.Interface(bus.get_object("org.neard", "/"), + "org.freedesktop.DBus.ObjectManager") + return manager.GetManagedObjects() + +def find_adapter(pattern=None): + return find_adapter_in_objects(get_managed_objects(), pattern) + +def find_adapter_in_objects(objects, pattern=None): + bus = dbus.SystemBus() + for path, ifaces in objects.iteritems(): + adapter = ifaces.get(ADAPTER_INTERFACE) + if adapter is None: + continue + if not pattern or path.endswith(pattern): + obj = bus.get_object(SERVICE_NAME, path) + return dbus.Interface(obj, ADAPTER_INTERFACE) + raise Exception("NFC adapter not found") + +def find_device(pattern=None): + return find_device_in_objects(get_managed_objects(), pattern) + +def find_device_in_objects(objects, pattern=None): + bus = dbus.SystemBus() + for path, ifaces in objects.iteritems(): + device = ifaces.get(DEVICE_INTERFACE) + if device is None: + continue + if not pattern or path.endswith(pattern): + obj = bus.get_object(SERVICE_NAME, path) + return dbus.Interface(obj, DEVICE_INTERFACE) + raise Exception("NFC device not found") + +def find_tag(pattern=None): + return find_tag_in_objects(get_managed_objects(), pattern) + +def find_tag_in_objects(objects, pattern=None): + bus = dbus.SystemBus() + for path, ifaces in objects.iteritems(): + tag = ifaces.get(TAG_INTERFACE) + if tag is None: + continue + if not pattern or path.endswith(pattern): + obj = bus.get_object(SERVICE_NAME, path) + return dbus.Interface(obj, TAG_INTERFACE) + raise Exception("NFC tag not found") + +def find_record(pattern=None): + return find_record_in_objects(get_managed_objects(), pattern) + +def find_record_in_objects(objects, pattern=None): + bus = dbus.SystemBus() + for path, ifaces in objects.iteritems(): + record = ifaces.get(RECORD_INTERFACE) + if record is None: + continue + if not pattern or path.endswith(pattern): + obj = bus.get_object(SERVICE_NAME, path) + return dbus.Interface(obj, RECORD_INTERFACE) + raise Exception("NFC record not found") + +def dump_record(record_path): + bus = dbus.SystemBus() + record_prop = dbus.Interface(bus.get_object("org.neard", record_path), + "org.freedesktop.DBus.Properties") + + properties = record_prop.GetAll(RECORD_INTERFACE) + + for key in properties.keys(): + if key in ["Representation"]: + val = unicode(properties[key]) + else: + val = str(properties[key]) + print " %s = %s" % (key, val) + +def dump_all_records(path): + bus = dbus.SystemBus() + om = dbus.Interface(bus.get_object("org.neard", "/"), + "org.freedesktop.DBus.ObjectManager") + objects = om.GetManagedObjects() + for path, interfaces in objects.iteritems(): + if "org.neard.Record" not in interfaces: + continue + + if path.startswith(path): + print(" [ %s ]" % (path)) + dump_record(path)
diff --git a/neard/test/phdc-simple-manager b/neard/test/phdc-simple-manager new file mode 100755 index 0000000..4fd25df --- /dev/null +++ b/neard/test/phdc-simple-manager
@@ -0,0 +1,193 @@ +#!/usr/bin/env python2.7 + +import sys +import dbus +import dbus.service +import dbus.glib +import gobject +import socket +import string +import struct +import threading +from threading import Thread +import time +from dbus.mainloop.glib import DBusGMainLoop + +# IDs specific to Linux nfc +AF_NFC = 39 +SOL_NFC = 280 +NFC_LLCP_MIUX = 1 + +# Sample test code - compliant with nfcpy phdc test agent +thermometer_assoc_req = \ + "E200 0032 8000 0000" \ + "0001 002A 5079 0026" \ + "8000 0000 A000 8000" \ + "0000 0000 0000 0080" \ + "0000 0008 3132 3334" \ + "3536 3738 0320 0001" \ + "0100 0000 0000" + +thermometer_assoc_res = \ + "E300 002C 0003 5079" \ + "0026 8000 0000 8000" \ + "8000 0000 0000 0000" \ + "8000 0000 0008 3837" \ + "3635 3433 3231 0000" \ + "0000 0000 0000 0000" \ + +assoc_release_req = "E40000020000" +assoc_release_res = "E50000020000" + +#======================================== +# Display helper +def hexdump( chars, sep, width ): + while chars: + line = chars[:width] + chars = chars[width:] + line = line.ljust( width, '\000' ) + print "%s%s%s" % ( sep.join( "%02x" % ord(c) for c in line ), + sep, quotechars( line )) + + +def quotechars( chars ): + return ''.join( ['.', c][c.isalnum()] for c in chars ) + +#======================================== +class PhdcPeerManager: + def __init__(self, agent_fd): + #Grab the agent .... + print 'Init PhdcPeerManager thread' + self.r_fd = agent_fd.take() + print 'Agent fd:', str(self.r_fd) + + def run( self): + print 'Run PhdcPeerManager thread: ', str(self.r_fd) + self.sock = socket.fromfd(self.r_fd, AF_NFC, socket.SOCK_STREAM) + try: + while True: + miu = self.sock.getsockopt(SOL_NFC, NFC_LLCP_MIUX) + print 'MIU=', miu + + while True: + data = self.sock.recv(16) + if data == None: + print 'no data' + break + + #analyze frame + print 'analyze' + size = struct.unpack(">H", data[0:2])[0] + apdu = data[2:] + + #should i read more data ? + while len(apdu) < size: + data = self.sock.recv(10) + if data == None: break + hexdump(data, ':', 16) + apdu += data + print "[ieee] <<< {0}".format(str(apdu).encode("hex")) + if apdu.startswith("\xE2\x00"): + apdu = bytearray.fromhex(thermometer_assoc_res) + elif apdu.startswith("\xE4\x00"): + apdu = bytearray.fromhex(assoc_release_res) + else: + apdu = apdu[::-1] + time.sleep(0.2) + print "[ieee] >>> {0}".format(str(apdu).encode("hex")) + data = struct.pack(">H", len(apdu)) + apdu + for i in range(0, len(data), miu): + self.sock.send(str(data[i:i+miu])) + + print "remote peer {0} closed connection".format(agent_fd) + print "leaving ieee manager" + self.sock.close() + + except IOError as e: + if e.errno == errno.EPIPE: + print 'Remote disconnect' + else: + print "I/O error({0}): {1}".format(e.errno, e.strerror) + finally: + print 'Finally exit' + stop() + + def stop(self): + print 'Stop PhdcPeerManager:', str(self.r_fd) + self._Thread__stop() + +#=================================================== +''' Phdc Manager Class +''' +class SimplePhdcManager(dbus.service.Object): + + @dbus.service.method('org.neard.PHDC.Manager', + in_signature='', + out_signature='') + def Release(self): + print 'Release' + mainloop.quit() + + + ''' Called on incoming agents + ''' + @dbus.service.method('org.neard.PHDC.Manager', + in_signature='h', + out_signature='') + def NewConnection(self, agent_fd): + print'Launch Phdc Manager thread for fd:', str(agent_fd) + self.server = PhdcPeerManager(agent_fd) + print'Run Server' + self.server.run() + print'Leave Server' + return + + ''' Called when the agent ends (from phdc_close) + ''' + @dbus.service.method('org.neard.PHDC.Manager', + in_signature='hi', out_signature='') + def Disconnection(self,agent_fd, i_err): + print'Stop Phdc Manager thread' + self.server.stop() + return + +''' Main loop +This sample installs two PHDC Managers: + * Simple: simulates a thermometer data exchange + * Validation: Validation Manager for NFC Forum PHDC) +''' +if "__main__" == __name__: + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + print 'PHDC Simple Manager Test' + bus = dbus.SystemBus() + obj = bus.get_object("org.neard", "/org/neard"); + neard_manager = dbus.Interface(obj, "org.neard.PHDC") + + simple_path = '/Simple' + valid_path = '/Validation' + + print 'Creating & registering PHDC Simple Manager' + simpleobject = SimplePhdcManager(bus, simple_path) + + d = dbus.Dictionary({'Role': 'Manager', 'Path': simple_path, + 'ServiceName': 'urn:nfc:sn:phdc' }, signature='sv') + neard_manager.RegisterAgent(d) + + print 'Creating & Registering Validation Manager' + + validationobj= SimplePhdcManager(bus, valid_path) + d = dbus.Dictionary({'Role': 'Manager', 'Path': valid_path, + 'ServiceName': 'urn:nfc:xsn:nfc-forum.org:phdc-validation' }, + signature='sv') + neard_manager.RegisterAgent(d) + + mainloop = gobject.MainLoop() + +try: + mainloop.run() + +except(KeyboardInterrupt): + #Call for unregister... + neard_manager.UnregisterAgent(simple_path, 'Manager') + neard_manager.UnregisterAgent(valid_path, 'Manager')
diff --git a/neard/test/test-adapter b/neard/test/test-adapter new file mode 100755 index 0000000..70d5d6a --- /dev/null +++ b/neard/test/test-adapter
@@ -0,0 +1,109 @@ +#!/usr/bin/python + +import sys +import dbus +import neardutils + +bus = dbus.SystemBus() + +def extract_list(list): + val = "[" + for i in list: + val += " " + str(i) + val += " ]" + return val + +def usage(): + print("Usage: %s <command>" % (sys.argv[0]) ) + print("") + print(" list") + print(" powered nfcX [on/off]") + print(" poll nfcX [on/off] [Initiator/Target/Dual]") + sys.exit(1) + +if (len(sys.argv) < 2): + usage() + +if (sys.argv[1] == "list"): + if (len(sys.argv) < 3): + om = dbus.Interface(bus.get_object("org.neard", "/"), + "org.freedesktop.DBus.ObjectManager") + objects = om.GetManagedObjects() + for path, interfaces in objects.iteritems(): + if "org.neard.Adapter" not in interfaces: + continue + + print(" [ %s ]" % (path)) + + props = interfaces["org.neard.Adapter"] + + for (key, value) in props.items(): + if (key == "Protocols"): + val = extract_list(value) + print(" %s = %s" % (key, val)) + + elif key in ["Powered", "Polling"]: + if value == dbus.Boolean(1): + val = "true" + else: + val = "false" + print(" %s = %s" % (key, val)) + + else: + print(" %s = %s" % (key, value)) + + sys.exit(0) + +if (sys.argv[1] == "powered"): + if (len(sys.argv) < 4): + usage() + else: + path = "/org/neard/" + sys.argv[2] + + adapter_path = neardutils.find_adapter(path).object_path + adapter = dbus.Interface(bus.get_object("org.neard", adapter_path), + "org.freedesktop.DBus.Properties") + + if (sys.argv[3] == "on"): + value = dbus.Boolean(1) + elif (sys.argv[3] == "off"): + value = dbus.Boolean(0) + else: + value = dbus.Boolean(sys.argv[3]) + try: + adapter.Set("org.neard.Adapter", "Powered", value) + except dbus.DBusException, error: + print "%s: %s" % (error._dbus_error_name, error.message) + sys.exit(0) + +if (sys.argv[1] == "poll"): + if (len(sys.argv) < 4): + usage() + else: + path = "/org/neard/" + sys.argv[2] + + adapter = neardutils.find_adapter(path) + + if (sys.argv[3] == "on"): + if (len(sys.argv) == 4): + mode = "Initiator" + else: + mode = sys.argv[4] + + try: + adapter.StartPollLoop(mode) + except dbus.DBusException, error: + print "%s: %s" % (error._dbus_error_name, error.message) + + elif (sys.argv[3] == "off"): + try: + adapter.StopPollLoop() + except dbus.DBusException, error: + print "%s: %s" % (error._dbus_error_name, error.message) + + else: + usage() + + sys.exit(0) + +usage()
diff --git a/neard/test/test-device b/neard/test/test-device new file mode 100755 index 0000000..a4923fb --- /dev/null +++ b/neard/test/test-device
@@ -0,0 +1,120 @@ +#!/usr/bin/python + +import sys +import dbus +import neardutils + +bus = dbus.SystemBus() + +def extract_list(list): + val = "[" + for i in list: + val += " " + str(i) + val += " ]" + return val + +def usage(): + print("Usage: %s <command>" % (sys.argv[0]) ) + print("") + print(" list") + print(" dump <device>") + print(" push <device> <type> <...>") + print " If type is Text, parameters are <encoding> <language> <representation>" + print " If type is URI, parameters are <uri>" + print " If type is SmartPoster, parameters are <uri>" + print " If type is Handover, parameters are <carrier>" + print " If type is StaticHandover, parameters are <carrier>" + print " If type is MIME, parameters are <mime_type> (only wifi_wsc and raw)" + print " raw is for sending raw payload, parameters are <mime_type> <payload>" + print "e.g. < %s push /org/neard/nfc0/device0 Text UTF-8 en-US hello,Type2! >" % (sys.argv[0]) + print "e.g. < %s push /org/neard/nfc0/device0 URI http://www.nfc-forum.com >" % (sys.argv[0]) + print "e.g. < %s push /org/neard/nfc0/device0 SmartPoster http://www.nfc-forum.com >" % (sys.argv[0]) + print "e.g. < %s push /org/neard/nfc0/device0 Handover bluetooth,wifi >" % (sys.argv[0]) + print "e.g. < %s push /org/neard/nfc0/device0 StaticHandover bluetooth,wifi >" % (sys.argv[0]) + print "e.g. < %s push /org/neard/nfc0/device0 MIME wifi_wsc>" % (sys.argv[0]) + print "e.g. < %s push /org/neard/nfc0/device0 MIME raw application/xml '<your><xml tags></your>' >" % (sys.argv[0]) + + sys.exit(1) + +if (len(sys.argv) < 2): + usage() + +if (sys.argv[1] == "list"): + if (len(sys.argv) < 3): + om = dbus.Interface(bus.get_object("org.neard", "/"), + "org.freedesktop.DBus.ObjectManager") + objects = om.GetManagedObjects() + for path, interfaces in objects.iteritems(): + if "org.neard.Device" not in interfaces: + continue + + print(" [ %s ]" % (path)) + + props = interfaces["org.neard.Device"] + + for (key, value) in props.items(): + print(" %s = %s" % (key, value)) + + sys.exit(0) + +if (sys.argv[1] == "dump"): + if (len(sys.argv) < 3): + om = dbus.Interface(bus.get_object("org.neard", "/"), + "org.freedesktop.DBus.ObjectManager") + objects = om.GetManagedObjects() + for path, interfaces in objects.iteritems(): + if "org.neard.Device" not in interfaces: + continue + + print("[ %s ]" % (path)) + neardutils.dump_all_records(path) + + sys.exit(0) + else: + neardutils.dump_all_records(sys.argv[2]) + + sys.exit(0) + +if (sys.argv[1] == "push"): + if (len(sys.argv) < 5): + usage() + + device = neardutils.find_device(sys.argv[2]) + + if len(sys.argv) == 7: + if sys.argv[3] in ["Text"]: + device.Push(({ "Type" : "Text", + "Encoding" : sys.argv[4], + "Language" : sys.argv[5], + "Representation" : sys.argv[6] })) + elif sys.argv[3] in ["MIME"]: + if sys.argv[4] in ["raw"]: + device.Push(({ "Type" : "MIME", + "MIME" : sys.argv[5], + "Payload" : dbus.ByteArray(sys.argv[6]) })) + else: + usage() + + elif len(sys.argv) == 5: + if sys.argv[3] in ["URI"]: + device.Push(({ "Type" : "URI", + "URI" : sys.argv[4] })) + elif sys.argv[3] in ["SmartPoster"]: + device.Push(({ "Type" : "SmartPoster", + "URI" : sys.argv[4] })) + elif sys.argv[3] in ["Handover"]: + device.Push(({ "Type" : "Handover", + "Carrier" : sys.argv[4] })) + elif sys.argv[3] in ["StaticHandover"]: + device.Push(({ "Type" : "StaticHandover", + "Carrier" : sys.argv[4] })) + elif sys.argv[3] in ["MIME"]: + if sys.argv[4] in ["wifi_wsc"]: + device.Push(({ "Type" : "MIME", + "MIME" : "application/vnd.wfa.wsc"})) + else: + usage() + else: + usage() + + sys.exit(0)
diff --git a/neard/test/test-tag b/neard/test/test-tag new file mode 100755 index 0000000..3d2c226 --- /dev/null +++ b/neard/test/test-tag
@@ -0,0 +1,136 @@ +#!/usr/bin/python + +import sys +import dbus +import neardutils + +bus = dbus.SystemBus() + +def extract_list(list): + val = "[" + for i in list: + val += " " + str(i) + val += " ]" + return val + +def usage(): + print("Usage: %s <command>" % (sys.argv[0]) ) + print("") + print(" list") + print(" dump <tag>") + print(" write <tag> <type> <...>") + print " If type is Text, parameters are <encoding> <language> <representation>" + print " If type is URI, parameters are <uri>" + print " If type is SmartPoster, parameters are <uri>" + print " If type is SMS, parameters are <phone number> <text>" + print " If type is E-Mail, parameters are <e-mail address>" + print " If type is MIME, and WiFi AP is passphrase protected" + print " Type is MIME, parameters are wifi_wsc <ssid> <passphrase>" + print " If type is MIME, and WiFi AP is open network" + print " Type is MIME, parameters are wifi_wsc <ssid>" + print "e.g. < %s /org/neard/nfc0/tag0 Text UTF-8 en-US hello,NFC! >" % (sys.argv[0]) + print "e.g. < %s /org/neard/nfc0/tag0 URI http://www.nfc-forum.com >" % (sys.argv[0]) + print "e.g. < %s /org/neard/nfc0/tag0 SmartPoster http://www.nfc-forum.com >" % (sys.argv[0]) + print "e.g. < %s /org/neard/nfc0/tag0 SMS 0102030405 YourSMSMessage >" % (sys.argv[0]) + print "e.g. < %s /org/neard/nfc0/tag0 E-Mail test@test.com >" % (sys.argv[0]) + print "e.g. < %s /org/neard/nfc0/tag0 MIME wifi_wsc YourAPname passphrase >" % (sys.argv[0]) + print "e.g. < %s /org/neard/nfc0/tag0 MIME wifi_wsc YourAPname >" % (sys.argv[0]) + + + sys.exit(1) + +if (len(sys.argv) < 2): + usage() + +if (sys.argv[1] == "list"): + if (len(sys.argv) < 3): + om = dbus.Interface(bus.get_object("org.neard", "/"), + "org.freedesktop.DBus.ObjectManager") + objects = om.GetManagedObjects() + for path, interfaces in objects.iteritems(): + if "org.neard.Tag" not in interfaces: + continue + + print(" [ %s ]" % (path)) + + props = interfaces["org.neard.Tag"] + + for (key, value) in props.items(): + if key in ["ReadOnly"]: + if value == dbus.Boolean(1): + val = "true" + else: + val = "false" + print(" %s = %s" % (key, val)) + + else: + print(" %s = %s" % (key, value)) + + sys.exit(0) + +if (sys.argv[1] == "dump"): + if (len(sys.argv) < 3): + om = dbus.Interface(bus.get_object("org.neard", "/"), + "org.freedesktop.DBus.ObjectManager") + objects = om.GetManagedObjects() + for path, interfaces in objects.iteritems(): + if "org.neard.Tag" not in interfaces: + continue + + print("[ %s ]" % (path)) + neardutils.dump_all_records(path) + + sys.exit(0) + else: + neardutils.dump_all_records(sys.argv[2]) + + sys.exit(0) + +if (sys.argv[1] == "write"): + if (len(sys.argv) < 5): + usage() + + tag = neardutils.find_tag(sys.argv[2]) + + if sys.argv[3] in ["Text"]: + tag.Write(({ "Type" : "Text", + "Encoding" : sys.argv[4], + "Language" : sys.argv[5], + "Representation" : sys.argv[6] })) + + elif sys.argv[3] in ["URI"]: + tag.Write(({ "Type" : "URI", + "URI" : sys.argv[4] })) + + elif sys.argv[3] in ["SmartPoster"]: + tag.Write(({ "Type" : "SmartPoster", + "URI" : sys.argv[4] })) + + elif sys.argv[3] in ["SMS"]: + URI = "sms:" + sys.argv[4] + "?body=" + sys.argv[5] + tag.Write(({ "Type" : "URI", + "URI" : URI })) + + elif sys.argv[3] in ["E-Mail"]: + URI = "mailto:" + sys.argv[4] + tag.Write(({ "Type" : "URI", + "URI" : URI })) + + elif sys.argv[3] in ["MIME"]: + if len(sys.argv) == 6: + if sys.argv[4] in ["wifi_wsc"]: + tag.Write(({ "Type" : "MIME", + "MIME" : "application/vnd.wfa.wsc", + "SSID" : sys.argv[5] })) + + elif len(sys.argv) == 7: + if sys.argv[4] in ["wifi_wsc"]: + tag.Write(({ "Type" : "MIME", + "MIME" : "application/vnd.wfa.wsc", + "SSID" : sys.argv[5], + "Passphrase" : sys.argv[6] })) + else: + usage() + +else: + usage()
diff --git a/neard/tools/nfctool/adapter.c b/neard/tools/nfctool/adapter.c new file mode 100644 index 0000000..beaee53 --- /dev/null +++ b/neard/tools/nfctool/adapter.c
@@ -0,0 +1,218 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <string.h> +#include <sys/socket.h> +#include <glib.h> + +#include <near/nfc_copy.h> + +#include "adapter.h" +#include "nfctool.h" +#include "netlink.h" + +static GSList *adapters; + +static struct nfc_adapter *selected_adapter; + +static void adapter_get_devices(struct nfc_adapter *adapter) +{ + if (adapter->rf_mode == NFC_RF_INITIATOR) + nl_get_targets(adapter); + + nl_get_params(adapter); +} + +int adapter_all_get_devices(void) +{ + int err; + + err = nl_get_devices(); + if (err) + return err; + + g_slist_foreach(adapters, (GFunc)adapter_get_devices, NULL); + + return 0; +} + +static void adapter_print_target(guint32 idx, gchar *type) +{ + printf("%s%d ", type, idx); +} + +void adpater_print_targets(struct nfc_adapter *adapter, gchar *prefix) +{ + printf("%sTags: [ ", prefix); + + g_slist_foreach(adapter->tags, (GFunc)adapter_print_target, "tag"); + + printf("]\n"); + + printf("%sDevices: [ ", prefix); + + g_slist_foreach(adapter->devices, + (GFunc)adapter_print_target, "device"); + + printf("]\n"); +} + +void adapter_print_info(struct nfc_adapter *adapter) +{ + gchar *rf_mode_str; + + if (!adapter) + return; + + printf("nfc%d:\n", adapter->idx); + + adpater_print_targets(adapter, " "); + + printf(" Protocols: [ "); + + if (adapter->protocols & NFC_PROTO_FELICA_MASK) + printf("Felica "); + + if (adapter->protocols & NFC_PROTO_MIFARE_MASK) + printf("MIFARE "); + + if (adapter->protocols & NFC_PROTO_JEWEL_MASK) + printf("Jewel "); + + if ((adapter->protocols & NFC_PROTO_ISO14443_MASK) || + (adapter->protocols & NFC_PROTO_ISO14443_B_MASK)) + printf("ISO-DEP "); + + if (adapter->protocols & NFC_PROTO_NFC_DEP_MASK) + printf("NFC-DEP "); + + if (adapter->protocols & NFC_PROTO_ISO15693_MASK) + printf("ISO-15693 "); + + printf("]\n"); + + printf(" Powered: %s\n", + adapter->powered ? "Yes" : "No"); + + if (adapter->rf_mode == NFC_RF_INITIATOR) + rf_mode_str = "Initiator"; + else if (adapter->rf_mode == NFC_RF_TARGET) + rf_mode_str = "Target"; + else + rf_mode_str = "None"; + + printf(" RF Mode: %s\n", rf_mode_str); + + printf(" lto: %d\n", adapter->param_lto); + printf(" rw: %d\n", adapter->param_rw); + printf(" miux: %d\n", adapter->param_miux); + + printf("\n"); +} + +void adapter_idx_print_info(guint32 idx) +{ + if (idx != INVALID_ADAPTER_IDX) + adapter_print_info(adapter_get(idx)); + else + g_slist_foreach(adapters, (GFunc)adapter_print_info, NULL); +} + +static gint adapter_compare_idx(struct nfc_adapter *adapter, guint32 idx) +{ + return (gint)adapter->idx - (gint)idx; +} + +struct nfc_adapter *adapter_get(guint32 idx) +{ + GSList *elem; + + if (idx == opts.adapter_idx) + return selected_adapter; + + elem = g_slist_find_custom(adapters, GINT_TO_POINTER(idx), + (GCompareFunc)adapter_compare_idx); + + if (elem) + return elem->data; + + return NULL; +} + +void adapter_add_target(struct nfc_adapter *adapter, guint8 type, guint32 idx) +{ + DBG("adapter_idx: %d, target_type: %d, target_idx: %d", + adapter->idx, type, idx); + + if (type == TARGET_TYPE_TAG) + adapter->tags = g_slist_append(adapter->tags, + GINT_TO_POINTER(idx)); + else + adapter->devices = g_slist_append(adapter->devices, + GINT_TO_POINTER(idx)); +} + +void adapter_free(struct nfc_adapter *adapter) +{ + g_slist_free(adapter->tags); + g_slist_free(adapter->devices); + + g_free(adapter); +} + +struct nfc_adapter *adapter_add(guint32 idx, guint32 protocols, + guint8 powered, guint8 rf_mode) +{ + struct nfc_adapter *adapter; + + adapter = g_malloc0(sizeof(struct nfc_adapter)); + + adapter->idx = idx; + adapter->protocols = protocols; + adapter->powered = powered; + adapter->rf_mode = rf_mode; + + if (rf_mode == NFC_RF_TARGET) + adapter_add_target(adapter, TARGET_TYPE_DEVICE, 0); + + adapters = g_slist_append(adapters, adapter); + + if (idx == opts.adapter_idx) + selected_adapter = adapter; + + return adapter; +} + +void adapter_cleanup(void) +{ + g_slist_free_full(adapters, (GDestroyNotify)adapter_free); +} + +int adapter_init(void) +{ + adapters = NULL; + selected_adapter = NULL; + + return 0; +}
diff --git a/neard/tools/nfctool/adapter.h b/neard/tools/nfctool/adapter.h new file mode 100644 index 0000000..c22ded8 --- /dev/null +++ b/neard/tools/nfctool/adapter.h
@@ -0,0 +1,59 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __ADAPTER_H +#define __ADAPTER_H + +struct nfc_adapter { + guint32 idx; + guint32 protocols; + guint8 powered; + guint8 polling; + guint8 rf_mode; + GSList *tags; + GSList *devices; + gint32 param_lto; + gint32 param_rw; + gint32 param_miux; +}; + +int adapter_init(void); + +void adapter_cleanup(void); + +struct nfc_adapter *adapter_add(guint32 idx, guint32 protocols, + guint8 powered, guint8 rf_mode); + +void adapter_free(struct nfc_adapter *adapter); + +void adapter_add_target(struct nfc_adapter *adapter, guint8 type, guint32 idx); + +struct nfc_adapter *adapter_get(guint32 adapter_idx); + +int adapter_all_get_devices(void); + +void adapter_idx_print_info(guint32 idx); + +void adapter_print_info(struct nfc_adapter *adapter); + +void adpater_print_targets(struct nfc_adapter *adapter, gchar *prefix); + +#endif /* __ADAPTER_H */
diff --git a/neard/tools/nfctool/display.c b/neard/tools/nfctool/display.c new file mode 100644 index 0000000..773a003 --- /dev/null +++ b/neard/tools/nfctool/display.c
@@ -0,0 +1,67 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2011-2013 Intel Corporation + * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <errno.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <sys/wait.h> +#include <sys/prctl.h> +#include <sys/ioctl.h> + +#include "display.h" + +static pid_t pager_pid = 0; + +bool use_color(void) +{ + static int cached_use_color = -1; + + if (__builtin_expect(!!(cached_use_color < 0), 0)) + cached_use_color = isatty(STDOUT_FILENO) > 0 || pager_pid > 0; + + return cached_use_color; +} + +int num_columns(void) +{ + static int cached_num_columns = -1; + + if (__builtin_expect(!!(cached_num_columns < 0), 0)) { + struct winsize ws; + + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0) + return -1; + + if (ws.ws_col > 0) + cached_num_columns = ws.ws_col; + } + + return cached_num_columns; +}
diff --git a/neard/tools/nfctool/display.h b/neard/tools/nfctool/display.h new file mode 100644 index 0000000..742eaea --- /dev/null +++ b/neard/tools/nfctool/display.h
@@ -0,0 +1,57 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2011-2013 Intel Corporation + * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <stdbool.h> + +bool use_color(void); + +#define COLOR_OFF "\x1B[0m" +#define COLOR_BLACK "\x1B[0;30m" +#define COLOR_RED "\x1B[0;31m" +#define COLOR_GREEN "\x1B[0;32m" +#define COLOR_YELLOW "\x1B[0;33m" +#define COLOR_BLUE "\x1B[0;34m" +#define COLOR_MAGENTA "\x1B[0;35m" +#define COLOR_CYAN "\x1B[0;36m" +#define COLOR_WHITE "\x1B[0;37m" +#define COLOR_WHITE_BG "\x1B[0;47m" +#define COLOR_HIGHLIGHT "\x1B[1;39m" + +#define COLOR_ERROR "\x1B[1;31m" + +#define print_indent(indent, color, fmt, args...) \ +do { \ + printf("%*c%s" fmt " %s\n", (indent), ' ', \ + use_color() ? (color) : "", ## args, \ + use_color() ? COLOR_OFF : ""); \ +} while (0) + +#define print_indent_prefix(indent, color1, prefix, color2, fmt, args...) \ +do { \ + printf("%*c%s%s%s" fmt "%s\n", (indent), ' ', \ + use_color() ? (color1) : "", prefix, \ + use_color() ? (color2) : "", ## args, \ + use_color() ? COLOR_OFF : ""); \ +} while (0) + +int num_columns(void);
diff --git a/neard/tools/nfctool/llcp-decode.c b/neard/tools/nfctool/llcp-decode.c new file mode 100644 index 0000000..7f95640 --- /dev/null +++ b/neard/tools/nfctool/llcp-decode.c
@@ -0,0 +1,632 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#include <stdio.h> +#include <glib.h> +#include <errno.h> +#include <string.h> +#include <netdb.h> +#include <sys/time.h> + +#include <near/nfc_copy.h> + +#include "nfctool.h" +#include "sniffer.h" +#include "ndef-decode.h" +#include "snep-decode.h" +#include "llcp-decode.h" + +/* Raw socket + LLCP headers */ +#define RAW_LLCP_HEADERS_SIZE 4 + +#define LLCP_PTYPE_SYMM 0 +#define LLCP_PTYPE_PAX 1 +#define LLCP_PTYPE_AGF 2 +#define LLCP_PTYPE_UI 3 +#define LLCP_PTYPE_CONNECT 4 +#define LLCP_PTYPE_DISC 5 +#define LLCP_PTYPE_CC 6 +#define LLCP_PTYPE_DM 7 +#define LLCP_PTYPE_FRMR 8 +#define LLCP_PTYPE_SNL 9 +#define LLCP_PTYPE_I 12 +#define LLCP_PTYPE_RR 13 +#define LLCP_PTYPE_RNR 14 + +#define LLCP_DM_NORMAL 0x00 +#define LLCP_DM_NO_ACTIVE_CONN 0x01 +#define LLCP_DM_NOT_BOUND 0x02 +#define LLCP_DM_REJECTED 0x03 +#define LLCP_DM_PERM_SAP_FAILURE 0x10 +#define LLCP_DM_PERM_ALL_SAP_FAILURE 0x11 +#define LLCP_DM_TMP_SAP_FAILURE 0x20 +#define LLCP_DM_TMP_ALL_SAP_FAILURE 0x21 + +enum llcp_param_t { + LLCP_PARAM_VERSION = 1, + LLCP_PARAM_MIUX, + LLCP_PARAM_WKS, + LLCP_PARAM_LTO, + LLCP_PARAM_RW, + LLCP_PARAM_SN, + LLCP_PARAM_OPT, + LLCP_PARAM_SDREQ, + LLCP_PARAM_SDRES, + + LLCP_PARAM_MIN = LLCP_PARAM_VERSION, + LLCP_PARAM_MAX = LLCP_PARAM_SDRES +}; + +static guint8 llcp_param_length[] = { + 0, + 1, + 2, + 2, + 1, + 1, + 0, + 1, + 0, + 2 +}; + +static char *llcp_ptype_str[] = { + "Symmetry (SYMM)", + "Parameter Exchange (PAX)", + "Aggregated Frame (AGF)", + "Unnumbered Information (UI)", + "Connect (CONNECT)", + "Disconnect (DISC)", + "Connection Complete (CC)", + "Disconnected Mode (DM)", + "Frame Reject (FRMR)", + "Service Name Lookup (SNL)", + "reserved", + "reserved", + "Information (I)", + "Receive Ready (RR)", + "Receive Not Ready (RNR)", + "reserved", + "Unknown" +}; + +static char *llcp_ptype_short_str[] = { + "SYMM", + "PAX", + "AGF", + "UI", + "CONNECT", + "DISC", + "CC", + "DM", + "FRMR", + "SNL", + NULL, + NULL, + "I", + "RR", + "RNR", + NULL, + "Unknown" +}; + +static const gchar *llcp_param_str[] = { + "", + "Version Number", + "Maximum Information Unit Extensions", + "Well-Known Service List", + "Link Timeout", + "Receive Window Size", + "Service Name", + "Option", + "Service Discovery Request", + "Service Discovery Response" +}; + +#define llcp_printf_header(prefix, color, fmt, ...) \ + print_indent_prefix( LLCP_HEADER_INDENT,\ + color, prefix, \ + LLCP_COLOR, fmt, ## __VA_ARGS__) + +#define llcp_printf_msg(fmt, ...) print_indent(LLCP_MSG_INDENT, \ + LLCP_COLOR, fmt, ## __VA_ARGS__) + +#define llcp_printf_error(fmt, ...) print_indent(LLCP_MSG_INDENT, \ + COLOR_ERROR, fmt, ## __VA_ARGS__) + +#define llcp_get_param_str(param_type) llcp_param_str[param_type] + +#define llcp_get_param_len(param_type) llcp_param_length[param_type] + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +static struct timeval start_timestamp; + +static GHashTable *connection_hash; + +/* We associate an SN from a CONNECT to its sender */ +static void llcp_add_connection_sn(struct sniffer_packet *packet, gchar *sn) +{ + guint8 ssap; + + if (packet->llcp.ptype != LLCP_PTYPE_CONNECT) + return; + + /* If we're sending the CONNECT, we use our local SAP*/ + if (packet->llcp.local_sap != 0x1) + ssap = packet->llcp.local_sap; + else + ssap = packet->llcp.remote_sap; + + g_hash_table_replace(connection_hash, + GINT_TO_POINTER(ssap), g_strdup(sn)); +} + +/* Check if there's a pending SN for this dsap */ +static void llcp_check_cc(struct sniffer_packet *packet) +{ + guint8 dsap; + gchar *sn; + + if (packet->llcp.ptype != LLCP_PTYPE_CC) + return; + + /* Find the real destination SAP for this CC */ + if (packet->direction == NFC_LLCP_DIRECTION_RX) + dsap = packet->llcp.local_sap; + else + dsap = packet->llcp.remote_sap; + + /* Do we have a CONNECT pending for this SAP ?*/ + sn = g_hash_table_lookup(connection_hash, + GINT_TO_POINTER(dsap)); + if (!sn) + return; + + if (strcmp(sn, "urn:nfc:sn:handover") == 0) + opts.handover_sap = dsap; +} + +static void free_connection(gpointer data) +{ + gchar *sn = data; + + g_free(sn); +} + +static void llcp_print_params(struct sniffer_packet *packet) +{ + guint8 major, minor; + guint16 miux, wks, tid; + guint32 offset = 0; + guint32 rmng; + guint8 *param; + guint8 param_len; + gchar *sn, param_str[64]; + + while (packet->llcp.data_len - offset >= 3) { + param = packet->llcp.data + offset; + rmng = packet->llcp.data_len - offset; + + if (param[0] < LLCP_PARAM_MIN || param[0] > LLCP_PARAM_MAX) { + llcp_printf_error("Error decoding params"); + return; + } + + param_len = llcp_get_param_len(param[0]); + + if (param_len == 0) + param_len = param[1]; + + if (param_len != param[1] || rmng < 2u + param_len) { + llcp_printf_error("Error decoding params"); + return; + } + + switch ((enum llcp_param_t)param[0]) { + case LLCP_PARAM_VERSION: + major = (param[2] & 0xF0) >> 4; + minor = param[2] & 0x0F; + sprintf(param_str, "%d.%d", major, minor); + break; + + case LLCP_PARAM_MIUX: + miux = ((param[2] & 0x07) << 8) | param[3]; + sprintf(param_str, "%d", miux); + break; + + case LLCP_PARAM_WKS: + wks = (param[2] << 8) | param[3]; + sprintf(param_str, "0x%02hX", wks); + break; + + case LLCP_PARAM_LTO: + sprintf(param_str, "%d", param[2]); + break; + + case LLCP_PARAM_RW: + sprintf(param_str, "%d", param[2] & 0x0F); + break; + + case LLCP_PARAM_SN: + sn = g_strndup((gchar *)param + 2, param_len); + llcp_add_connection_sn(packet, sn); + snprintf(param_str, 64, "%s", sn); + g_free(sn); + break; + + case LLCP_PARAM_OPT: + sprintf(param_str, "0x%X", param[2] & 0x03); + break; + + case LLCP_PARAM_SDREQ: + tid = param[2]; + sn = g_strndup((gchar *)param + 3, param_len - 1); + snprintf(param_str, 64, "TID:%d, SN:%s", tid, sn); + g_free(sn); + break; + + case LLCP_PARAM_SDRES: + sprintf(param_str, "TID:%d, SAP:%d", param[2], param[3] & 0x3F); + break; + } + + llcp_printf_msg("%s: %s", llcp_get_param_str(param[0]), + param_str); + + offset += 2 + param_len; + } +} + +static int llcp_decode_packet(guint8 *data, guint32 data_len, + struct sniffer_packet *packet) +{ + if (data_len < RAW_LLCP_HEADERS_SIZE) + return -EINVAL; + + memset(packet, 0, sizeof(struct sniffer_packet)); + + /* LLCP raw socket header */ + packet->adapter_idx = data[0]; + packet->direction = data[1] & 0x01; + + /* LLCP header */ + if (packet->direction == NFC_LLCP_DIRECTION_TX) { + packet->llcp.remote_sap = (data[2] & 0xFC) >> 2; + packet->llcp.local_sap = data[3] & 0x3F; + } else { + packet->llcp.remote_sap = data[3] & 0x3F; + packet->llcp.local_sap = (data[2] & 0xFC) >> 2; + } + + packet->llcp.ptype = ((data[2] & 0x03) << 2) | ((data[3] & 0xC0) >> 6); + + if (packet->llcp.ptype >= ARRAY_SIZE(llcp_ptype_str)) + return -EINVAL; + + packet->llcp.data = data + RAW_LLCP_HEADERS_SIZE; + packet->llcp.data_len = data_len - RAW_LLCP_HEADERS_SIZE; + + /* Sequence field */ + if (packet->llcp.ptype >= LLCP_PTYPE_I) { + if (packet->llcp.data_len == 0) + return -EINVAL; + + packet->llcp.send_seq = ((packet->llcp.data[0] & 0xF0) >> 4); + packet->llcp.recv_seq = packet->llcp.data[0] & 0x0F; + + packet->llcp.data++; + packet->llcp.data_len--; + } + + return 0; +} + +static void llcp_print_sequence(struct sniffer_packet *packet) +{ + llcp_printf_msg("N(S):%d N(R):%d", + packet->llcp.send_seq, packet->llcp.recv_seq); +} + +static int llcp_print_agf(struct sniffer_packet *packet, + struct timeval *timestamp) +{ + guint8 *pdu; + gsize pdu_size; + gsize size; + guint16 offset; + guint16 count; + int err; + + if (packet->llcp.data_len < 2) { + llcp_printf_error("Error parsing AGF PDU"); + return -EINVAL; + } + + printf("\n"); + + pdu = NULL; + pdu_size = 0; + offset = 0; + count = 0; + + while (offset < packet->llcp.data_len - 2) { + size = (packet->llcp.data[offset] << 8) | + packet->llcp.data[offset + 1]; + + offset += 2; + + if (size == 0 || offset + size > packet->llcp.data_len) { + llcp_printf_error("Error parsing AGF PDU"); + err = -EINVAL; + goto exit; + } + + if (size + NFC_LLCP_RAW_HEADER_SIZE > pdu_size) { + pdu_size = size + NFC_LLCP_RAW_HEADER_SIZE; + pdu = g_realloc(pdu, pdu_size); + + pdu[0] = packet->adapter_idx; + pdu[1] = packet->direction; + } + + memcpy(pdu + NFC_LLCP_RAW_HEADER_SIZE, + packet->llcp.data + offset, size); + + llcp_printf_msg("-- AGF LLC PDU %02u:", count++); + + llcp_print_pdu(pdu, size + NFC_LLCP_RAW_HEADER_SIZE, timestamp); + + offset += size; + } + + llcp_printf_msg("-- End of AGF LLC PDUs"); + + err = 0; +exit: + g_free(pdu); + + return err; +} + +static int llcp_print_dm(struct sniffer_packet *packet) +{ + gchar *reason; + + if (packet->llcp.data_len != 1) + return -EINVAL; + + switch (packet->llcp.data[0]) { + case LLCP_DM_NORMAL: + default: + reason = "Normal disconnect"; + break; + + case LLCP_DM_NO_ACTIVE_CONN: + reason = + "No active connection for connection-oriented PDU at SAP"; + break; + + case LLCP_DM_NOT_BOUND: + reason = "No service bound to target SAP"; + break; + + case LLCP_DM_REJECTED: + reason = "CONNECT PDU rejected by service layer"; + break; + + case LLCP_DM_PERM_SAP_FAILURE: + reason = "Permanent failure for target SAP"; + break; + + case LLCP_DM_PERM_ALL_SAP_FAILURE: + reason = "Permanent failure for any target SAP"; + break; + + case LLCP_DM_TMP_SAP_FAILURE: + reason = "Temporary failure for target SAP"; + break; + + case LLCP_DM_TMP_ALL_SAP_FAILURE: + reason = "Temporary failure for any target SAP"; + break; + } + + llcp_printf_msg("Reason: %d (%s)", packet->llcp.data[0], reason); + + return 0; +} + +static int llcp_print_i(struct sniffer_packet *packet) +{ + llcp_print_sequence(packet); + + if (packet->llcp.local_sap == opts.snep_sap || + packet->llcp.remote_sap == opts.snep_sap) { + int err; + + err = snep_print_pdu(packet); + if (err != 0) + llcp_printf_error("Error decoding SNEP frame"); + + return err; + } else if (packet->llcp.local_sap == opts.handover_sap || + packet->llcp.remote_sap == opts.handover_sap) { + int err; + + err = ndef_print_records(packet->llcp.data, + packet->llcp.data_len); + if (err != 0) + llcp_printf_error("Error decoding Handover frame"); + return err; + } + + sniffer_print_hexdump(stdout, packet->llcp.data, packet->llcp.data_len, + LLCP_MSG_INDENT, TRUE); + + return 0; +} + +static int llcp_print_frmr(struct sniffer_packet *packet) +{ + guint8 info, ptype; + + if (packet->llcp.data_len != 4) + return -EINVAL; + + info = packet->llcp.data[0]; + ptype = info & 0x0F; + if (ptype >= ARRAY_SIZE(llcp_ptype_str)) + ptype = ARRAY_SIZE(llcp_ptype_str) - 1; + + llcp_printf_msg("W:%d I:%d R:%d S:%d PTYPE:%s SEQ: %d V(S):" + " %d V(R): %d V(SA): %d V(RA): %d", + (info & 0x80) >> 7, (info & 0x40) >> 6, + (info & 0x20) >> 5, (info & 0x10) >> 4, + llcp_ptype_short_str[ptype], packet->llcp.data[1], + (packet->llcp.data[2] & 0xF0) >> 4, + packet->llcp.data[2] & 0x0F, + (packet->llcp.data[3] & 0xF0) >> 4, + packet->llcp.data[3] & 0x0F); + + return 0; +} + +int llcp_print_pdu(guint8 *data, guint32 data_len, struct timeval *timestamp) +{ + struct timeval msg_timestamp; + struct sniffer_packet packet; + gchar *direction_str, time_str[32]; + gchar *direction_color; + int err; + + if (!timestamp) + return -EINVAL; + + if (!timerisset(&start_timestamp)) + start_timestamp = *timestamp; + + err = llcp_decode_packet(data, data_len, &packet); + if (err) + goto exit; + + if (!opts.dump_symm && packet.llcp.ptype == LLCP_PTYPE_SYMM) + return 0; + + if (packet.direction == NFC_LLCP_DIRECTION_RX) { + direction_str = ">>"; + direction_color = COLOR_RED; + } else { + direction_str = "<<"; + direction_color = COLOR_GREEN; + } + + time_str[0] = 0; + + if (opts.show_timestamp != SNIFFER_SHOW_TIMESTAMP_NONE) { + char prefix = ' '; + + if (opts.show_timestamp == SNIFFER_SHOW_TIMESTAMP_ABS) { + msg_timestamp = *timestamp; + } else { + timersub(timestamp, &start_timestamp, &msg_timestamp); + prefix = '+'; + } + + sprintf(time_str, "%c%lu.%06lus", prefix, msg_timestamp.tv_sec, + msg_timestamp.tv_usec); + } + + llcp_printf_header(direction_str, direction_color, + " nfc%d: local:0x%02x remote:0x%02x %s", + packet.adapter_idx, packet.llcp.local_sap, + packet.llcp.remote_sap, time_str); + + llcp_printf_msg("%s", llcp_ptype_str[packet.llcp.ptype]); + + switch (packet.llcp.ptype) { + case LLCP_PTYPE_AGF: + llcp_print_agf(&packet, timestamp); + break; + + case LLCP_PTYPE_I: + llcp_print_i(&packet); + break; + + case LLCP_PTYPE_RR: + case LLCP_PTYPE_RNR: + llcp_print_sequence(&packet); + break; + + case LLCP_PTYPE_PAX: + case LLCP_PTYPE_CONNECT: + case LLCP_PTYPE_CC: + case LLCP_PTYPE_SNL: + llcp_check_cc(&packet); + llcp_print_params(&packet); + break; + + case LLCP_PTYPE_DM: + llcp_print_dm(&packet); + break; + + case LLCP_PTYPE_FRMR: + llcp_print_frmr(&packet); + break; + + default: + sniffer_print_hexdump(stdout, packet.llcp.data, + packet.llcp.data_len, + LLCP_MSG_INDENT, TRUE); + break; + } + + printf("\n"); + + err = 0; + +exit: + return err; +} + +void llcp_decode_cleanup(void) +{ + timerclear(&start_timestamp); + + snep_decode_cleanup(); + + if (connection_hash) + g_hash_table_destroy(connection_hash); +} + +int llcp_decode_init(void) +{ + int err; + + timerclear(&start_timestamp); + + connection_hash = g_hash_table_new_full(g_direct_hash, + g_direct_equal, NULL, + free_connection); + + err = snep_decode_init(); + + return err; +}
diff --git a/neard/tools/nfctool/llcp-decode.h b/neard/tools/nfctool/llcp-decode.h new file mode 100644 index 0000000..d822769 --- /dev/null +++ b/neard/tools/nfctool/llcp-decode.h
@@ -0,0 +1,30 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef __LLCP_DECODE_H +#define __LLCP_DECODE_H + +int llcp_decode_init(void); + +void llcp_decode_cleanup(void); + +int llcp_print_pdu(guint8 *buffer, guint32 len, struct timeval *timestamp); + +#endif /* __LLCP_DECODE_H */
diff --git a/neard/tools/nfctool/main.c b/neard/tools/nfctool/main.c new file mode 100644 index 0000000..2bdf3f5 --- /dev/null +++ b/neard/tools/nfctool/main.c
@@ -0,0 +1,1068 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <string.h> +#include <sys/socket.h> +#include <glib.h> + +#include <netlink/genl/genl.h> + +#include <near/nfc_copy.h> + +#include <near/types.h> +#include <near/ndef.h> + +#include "../../src/near.h" + +#include "nfctool.h" +#include "adapter.h" +#include "netlink.h" +#include "sniffer.h" + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <stdint.h> +#include <string.h> +#include <sys/time.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <linux/socket.h> + +/* HACK HACK */ +#ifndef AF_NFC +#define AF_NFC 39 +#endif + +#define LLCP_MAX_LTO 0xff +#define LLCP_MAX_RW 0x0f +#define LLCP_MAX_MIUX 0x7ff + +#define OUI_LEN 4 +#define SUBCMD_LEN 4 + + +#define SNEP_VERSION 0x10 + +/* Request codes */ +#define SNEP_REQ_CONTINUE 0x00 +#define SNEP_REQ_GET 0x01 +#define SNEP_REQ_PUT 0x02 +#define SNEP_REQ_REJECT 0x7f + +/* Response codes */ +#define SNEP_RESP_CONTINUE 0x80 +#define SNEP_RESP_SUCCESS 0x81 +#define SNEP_RESP_NOT_FOUND 0xc0 +#define SNEP_RESP_EXCESS 0xc1 +#define SNEP_RESP_BAD_REQ 0xc2 +#define SNEP_RESP_NOT_IMPL 0xe0 +#define SNEP_RESP_VERSION 0xe1 +#define SNEP_RESP_REJECT 0xff + +struct p2p_snep_req_frame { + uint8_t version; + uint8_t request; + uint32_t length; + uint8_t ndef[]; +} __attribute__((packed)); + +static GMainLoop *main_loop = NULL; + +static int nfctool_poll_cb(guint8 cmd, guint32 idx, gpointer data); +static int nfctool_snl_cb(guint8 cmd, guint32 idx, gpointer data); + +static void nfctool_quit(bool force); + +static gchar *nfctool_poll_mode_str(int mode) +{ + if (mode == POLLING_MODE_TARGET) + return "target"; + + if (mode == POLLING_MODE_BOTH) + return "both initiator and target"; + + return "initiator"; +} + +static int nfctool_start_poll(void) +{ + int err; + + struct nfc_adapter *adapter; + + adapter = adapter_get(opts.adapter_idx); + + if (!adapter) { + print_error("Invalid adapter index: %d", opts.adapter_idx); + + return -ENODEV; + } + + nl_add_event_handler(NFC_EVENT_TARGETS_FOUND, nfctool_poll_cb); + nl_add_event_handler(NFC_EVENT_TM_ACTIVATED, nfctool_poll_cb); + + err = nl_start_poll(adapter, opts.poll_mode); + + if (err == 0) { + printf("Start polling on nfc%d as %s\n\n", + adapter->idx, nfctool_poll_mode_str(opts.poll_mode)); + return 0; + } + + if (err != -EBUSY) + return err; + + if (adapter->rf_mode == NFC_RF_NONE) + printf("nfc%d already in polling mode\n\n", adapter->idx); + else + printf("nfc%d already activated\n\n", adapter->idx); + + /* Don't fail if there is a pending SNL request */ + if (opts.snl) + return 0; + + return err; +} + +static int nfctool_set_params(void) +{ + struct nfc_adapter *adapter; + int err; + + adapter = adapter_get(opts.adapter_idx); + if (!adapter) + return -ENODEV; + + err = nl_set_params(adapter, opts.lto, opts.rw, opts.miux); + if (err) { + print_error("Error setting one of the parameters."); + goto exit; + } + + nl_get_params(adapter); + + adapter_print_info(adapter); + +exit: + return err; +} + +static int nfctool_snl_send_request(struct nfc_adapter *adapter) +{ + int err; + + nl_add_event_handler(NFC_EVENT_LLC_SDRES, nfctool_snl_cb); + + err = nl_send_sdreq(adapter, opts.snl_list); + if (err) + print_error("Can't send SNL request: %s", strerror(-err)); + + return err; +} + +static int nfctool_set_powered(bool powered) +{ + struct nfc_adapter *adapter; + int err; + + adapter = adapter_get(opts.adapter_idx); + if (!adapter) + return -ENODEV; + + err = nl_set_powered(adapter, powered); + + if (err == 0) + adapter->powered = powered; + + return err; +} + +static int nfctool_fw_download_cb(guint8 cmd, guint32 adapter_idx, + gpointer data) +{ + int err; + gchar *fw_filename; + struct nlattr **nl_attr = data; + + if (nl_attr[NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS] != NULL) + err = nla_get_u32(nl_attr[NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS]); + else + err = -ENOTSUP; + + if (nl_attr[NFC_ATTR_FIRMWARE_NAME] != NULL) + fw_filename = nla_get_string(nl_attr[NFC_ATTR_FIRMWARE_NAME]); + else + fw_filename = "UNKNOWN"; + + printf("Firmware download operation for %s terminated with status %s\n", + fw_filename, err ? strerror(-err) : "OK"); + + nfctool_quit(false); + + return 0; +} + +static int nfctool_fw_download(gchar *fw_filename) +{ + struct nfc_adapter *adapter; + int err; + + adapter = adapter_get(opts.adapter_idx); + if (!adapter) + return -ENODEV; + + nl_add_event_handler(NFC_CMD_FW_DOWNLOAD, nfctool_fw_download_cb); + + err = nl_fw_download(adapter, fw_filename); + if (err) + print_error("Firmware download failed: %s", strerror(-err)); + + return err; +} + +static int nfctool_dep_link_up_cb(guint8 cmd, guint32 idx, gpointer data) +{ + struct nfc_adapter *adapter; + + printf("Link is UP for adapter nfc%d\n\n", idx); + + if (idx != opts.adapter_idx) + return -ENODEV; + + adapter = adapter_get(idx); + if (!adapter) + return -ENODEV; + + nfctool_snl_send_request(adapter); + + return 0; +} + +static int nfctool_dep_link_down_cb(guint8 cmd, guint32 idx, gpointer data) +{ + if (idx != opts.adapter_idx) + return -ENODEV; + + printf("Link is DOWN for adapter nfc%d\n\n", idx); + + opts.snl = false; + + nfctool_quit(false); + + return 0; +} + +static int nfctool_snl(void) +{ + struct nfc_adapter *adapter; + + adapter = adapter_get(opts.adapter_idx); + if (!adapter) + return -ENODEV; + + if (adapter->polling) { + /* Delay netlink message until the link is established */ + nl_add_event_handler(NFC_CMD_DEP_LINK_UP, + nfctool_dep_link_up_cb); + + nl_add_event_handler(NFC_CMD_DEP_LINK_DOWN, + nfctool_dep_link_down_cb); + + return 0; + } + + if (adapter->rf_mode == NFC_RF_NONE) { + print_error("Can't send SNL request: No active link"); + + opts.snl = false; + + return -ENOLINK; + } + + return nfctool_snl_send_request(adapter); +} + +static void nfctool_send_dep_link_up(guint32 target_idx, guint32 adapter_idx) +{ + nl_send_dep_link_up(adapter_idx, target_idx); +} + +static int nfctool_snep_send(guint32 target_idx, guint32 adapter_idx) { + int fd, len; + struct near_ndef_message *ndef; + struct sockaddr_nfc_llcp addr; + struct p2p_snep_req_frame *frame; + size_t frame_length; + const char *uri_msg = "http://nfc-forum.org/"; + const char *txt_msg = "Hello world!"; + + DBG("target_idx=%d, adapter_idx=%d\n", target_idx, adapter_idx); + + fd = socket(AF_NFC, SOCK_STREAM, NFC_SOCKPROTO_LLCP); + if (fd < 0) + return -1; + + memset(&addr, 0, sizeof(struct sockaddr_nfc_llcp)); + addr.sa_family = AF_NFC; + addr.dev_idx = adapter_idx; + addr.target_idx = target_idx; + addr.nfc_protocol = NFC_PROTO_NFC_DEP; + addr.service_name_len = strlen("urn:nfc:sn:snep"); + strcpy(addr.service_name, "urn:nfc:sn:snep"); + + if (connect(fd, (struct sockaddr *)&addr, + sizeof(struct sockaddr_nfc_llcp)) < 0) { + printf("Connect error %s\n", strerror(errno)); + return -1; + } + + if (opts.push_snep_uri) + ndef = near_ndef_prepare_uri_record(0, strlen(uri_msg), uri_msg); + else + ndef = near_ndef_prepare_text_record("UTF-8", "en", txt_msg); + + if (!ndef) { + close(fd); + printf("Could not build NDEF"); + return -1; + } + + frame_length = sizeof(struct p2p_snep_req_frame) + ndef->length; + frame = g_try_malloc0(frame_length); + if (!frame) { + close(fd); + printf("Could not allocate SNEP frame"); + return -1; + } + + frame->version = SNEP_VERSION; + frame->request = SNEP_REQ_PUT; + frame->length = GUINT_TO_BE(ndef->length); + + memcpy(frame->ndef, ndef->data, ndef->length); + + len = send(fd, (uint8_t *)frame, frame_length, 0); + if (len < 0) { + printf("Could not send NDEF %s\n", strerror(errno)); + + g_free(frame); + close(fd); + + return -1; + } + + printf("Sent %d bytes\n", len); + + g_free(frame); + close(fd); + + return 0; +} + +static int nfctool_targets_found(guint32 adapter_idx) +{ + int err; + struct nfc_adapter *adapter; + + DBG("adapter_idx: %d", adapter_idx); + + if (adapter_idx == INVALID_ADAPTER_IDX) + return -ENODEV; + + adapter = adapter_get(adapter_idx); + + if (!adapter) + return -ENODEV; + + err = nl_get_targets(adapter); + if (err) { + print_error("Error getting targets\n"); + goto exit; + } + + printf("Targets found for nfc%d\n", adapter_idx); + adpater_print_targets(adapter, " "); + printf("\n"); + + if (adapter->polling) { + if (opts.push_snep_msg) + g_slist_foreach(adapter->devices, + (GFunc)nfctool_snep_send, + GINT_TO_POINTER(adapter_idx)); + else + g_slist_foreach(adapter->devices, + (GFunc)nfctool_send_dep_link_up, + GINT_TO_POINTER(adapter_idx)); + + adapter->polling = FALSE; + } + +exit: + return err; +} + +static int nfctool_initiator_found(guint32 adapter_idx) +{ + struct nfc_adapter *adapter; + + DBG("adapter_idx: %d", adapter_idx); + + if (adapter_idx == INVALID_ADAPTER_IDX) + return -ENODEV; + + adapter = adapter_get(adapter_idx); + + if (!adapter) + return -ENODEV; + + if (adapter->polling && opts.push_snep_msg) + nfctool_snep_send(0, adapter_idx); + + adapter->polling = FALSE; + + return 0; +} + +static int nfctool_poll_cb(guint8 cmd, guint32 idx, gpointer data) +{ + int err = 0; + + DBG("cmd: %d, idx: %d", cmd, idx); + + switch (cmd) { + case NFC_EVENT_TARGETS_FOUND: + err = nfctool_targets_found(idx); + break; + case NFC_EVENT_TM_ACTIVATED: + printf("Target mode activated\n"); + err = nfctool_initiator_found(idx); + break; + } + + nfctool_quit(false); + + return err; +} + +static void nfctool_print_and_remove_snl(struct nfc_snl *sdres, + guint32 adapter_idx) +{ + GSList *elem; + + printf(" uri: %s - sap: %d\n", sdres->uri, sdres->sap); + + if (adapter_idx == opts.adapter_idx) { + elem = g_slist_find_custom(opts.snl_list, sdres->uri, + (GCompareFunc)g_strcmp0); + + if (elem) { + g_free(elem->data); + opts.snl_list = g_slist_delete_link(opts.snl_list, + elem); + } + } +} + +static int nfctool_snl_cb(guint8 cmd, guint32 idx, gpointer data) +{ + GSList *sdres_list = (GSList *)data; + + printf("nfc%d: Service Name lookup:\n", idx); + + g_slist_foreach(sdres_list, (GFunc)nfctool_print_and_remove_snl, + GINT_TO_POINTER(idx)); + + printf("\n"); + + if (!opts.snl_list) { + opts.snl = false; + nfctool_quit(false); + } + + return 0; +} + +static int nfctool_send_vendor_cmd_cb(guint8 cmd, guint32 adapter_idx, + gpointer data) +{ + guint32 vendor; + guint32 sub_cmd; + gchar *rsp; + int rsp_len, i; + struct nlattr **nl_attr = data; + + if (nl_attr[NFC_ATTR_VENDOR_ID] != NULL) + vendor = nla_get_u32(nl_attr[NFC_ATTR_VENDOR_ID]); + else + vendor = 0; + + if (nl_attr[NFC_ATTR_VENDOR_SUBCMD] != NULL) + sub_cmd = nla_get_u32(nl_attr[NFC_ATTR_VENDOR_SUBCMD]); + else + sub_cmd = 0; + + printf("Vendor 0x%.8X response 0x%.8X with", vendor, sub_cmd); + + if (nl_attr[NFC_ATTR_VENDOR_DATA] != NULL) { + printf(" data:"); + rsp = nla_data(nl_attr[NFC_ATTR_VENDOR_DATA]); + rsp_len = nla_len(nl_attr[NFC_ATTR_VENDOR_DATA]); + for (i = 0; i < rsp_len; i++) + printf(" 0x%02X", rsp[i]); + puts(""); + } else { + puts("out data"); + rsp = NULL; + } + + nfctool_quit(false); + + return 0; +} + +static int nfctool_send_vendor_cmd(gchar *data) +{ + int err; + unsigned int index = 0; + struct nfc_adapter *adapter; + guint32 oui = 0; + guint32 sub_cmd = 0; + gchar buffer[9]; + gchar *ptr = data; + guint32 data_buffer_size = 0; + guint8 *data_buffer; + + adapter = adapter_get(opts.adapter_idx); + if (!adapter) { + print_error("Invalid adapter index: %d", opts.adapter_idx); + return -ENODEV; + } + + /* Each byte use 2 characters */ + data_buffer_size = strlen(ptr) / 2; + if (data_buffer_size < (OUI_LEN + SUBCMD_LEN)) + return -ENODATA; + + if (data_buffer_size > (OUI_LEN + SUBCMD_LEN)) { + data_buffer = g_malloc(data_buffer_size - 8); + if (!data_buffer) + return -ENOMEM; + } else { + data_buffer = NULL; + } + + /* Parse OUI */ + memcpy(buffer, ptr + index * 2, OUI_LEN * 2); + buffer[OUI_LEN * 2] = '\0'; + oui = strtol(buffer, NULL, 16); + index += OUI_LEN; + + /* Parse sub cmd code */ + memcpy(buffer, ptr + index * 2, SUBCMD_LEN * 2); + buffer[SUBCMD_LEN * 2] = '\0'; + sub_cmd = strtol(buffer, NULL, 16); + index += SUBCMD_LEN; + + /* Parse data */ + buffer[2] = '\0'; + for (; index < data_buffer_size; index++) { + memcpy(buffer, ptr + index * 2, 2); + data_buffer[index - OUI_LEN - SUBCMD_LEN] = (gchar) strtol(buffer, NULL, 16); + } + + nl_add_event_handler(NFC_EVENT_VENDOR_RSP, nfctool_send_vendor_cmd_cb); + + err = nl_send_vendor_cmd(adapter, oui, sub_cmd, + data_buffer_size - OUI_LEN - SUBCMD_LEN, + data_buffer); + g_free(data_buffer); + return err; +} + +struct nfc_snl *nfctool_snl_alloc(gsize uri_size) +{ + struct nfc_snl *snl; + + snl = g_malloc(sizeof(struct nfc_snl)); + + snl->uri = g_malloc0(uri_size); + snl->uri_size = uri_size; + snl->sap = 0; + + return snl; +} + +void nfctool_sdres_free(struct nfc_snl *snl) +{ + if (snl->uri_size) + g_free(snl->uri); + + g_free(snl); +} + +static volatile sig_atomic_t __terminated = 0; + +static void sig_term(int sig) +{ + if (__terminated > 0) + return; + + __terminated = 1; + + DBG("Terminating"); + + nfctool_quit(true); +} + +struct nfctool_options opts = { + .show_version = FALSE, + .list = FALSE, + .poll = FALSE, + .poll_mode = POLLING_MODE_INITIATOR, + .device_name = NULL, + .adapter_idx = INVALID_ADAPTER_IDX, + .enable_dev = FALSE, + .disable_dev = FALSE, + .set_param = FALSE, + .lto = -1, + .rw = -1, + .miux = -1, + .need_netlink = FALSE, + .snl = FALSE, + .snl_list = NULL, + .sniff = FALSE, + .snap_len = 0, + .dump_symm = FALSE, + .show_timestamp = SNIFFER_SHOW_TIMESTAMP_NONE, + .snep_sap = 0x04, + .pcap_filename = NULL, + .vendor_cmd = NULL, + .push_snep_msg = FALSE, + .push_snep_uri = TRUE, +}; + +static bool opt_parse_poll_arg(const gchar *option_name, const gchar *value, + gpointer data, GError **error) +{ + opts.poll = true; + + opts.poll_mode = POLLING_MODE_INITIATOR; + + if (value) { + if (*value == 't' || *value == 'T') + opts.poll_mode = POLLING_MODE_TARGET; + else if (*value == 'b' || *value == 'B') + opts.poll_mode = POLLING_MODE_BOTH; + } + + return true; +} + +static bool opt_parse_pushsnepmsg_arg(const gchar *option_name, const gchar *value, + gpointer data, GError **error) +{ + opts.push_snep_msg = true; + opts.poll_mode = POLLING_MODE_BOTH; + + if (value) { + if (*value == 't' || *value == 'T') + opts.push_snep_uri = FALSE; + } + + return true; +} + +static bool opt_parse_set_param_arg(const gchar *option_name, + const gchar *value, + gpointer data, GError **error) +{ + gchar **params = NULL, **keyval = NULL; + gchar *end; + gint i, intval; + bool result; + + params = g_strsplit(value, ",", -1); + + i = 0; + while (params[i]) { + keyval = g_strsplit(params[i], "=", 2); + + if (!keyval[0] || !keyval[1]) { + result = false; + goto exit; + } + + intval = strtol(keyval[1], &end, 10); + if (keyval[1] == end) { + result = false; + goto exit; + } + + if (g_ascii_strcasecmp(keyval[0], "lto") == 0) { + if (intval < 0 || intval > LLCP_MAX_LTO) { + print_error("Bad value: max lto value is %d", + LLCP_MAX_LTO); + result = false; + goto exit; + } + + opts.lto = intval; + } else if (g_ascii_strcasecmp(keyval[0], "rw") == 0) { + if (intval < 0 || intval > LLCP_MAX_RW) { + print_error("Bad value: max rw value is %d", + LLCP_MAX_RW); + result = false; + goto exit; + } + + opts.rw = intval; + } else if (g_ascii_strcasecmp(keyval[0], "miux") == 0) { + if (intval < 0 || intval > LLCP_MAX_MIUX) { + print_error("Bad value: max miux value is %d", + LLCP_MAX_MIUX); + result = false; + goto exit; + } + + opts.miux = intval; + } else { + result = false; + goto exit; + } + + opts.set_param = true; + + g_strfreev(keyval); + keyval = NULL; + + i++; + } + + result = true; + +exit: + if (params) + g_strfreev(params); + + if (keyval) + g_strfreev(keyval); + + return result; +} + +static bool opt_parse_show_timestamp_arg(const gchar *option_name, + const gchar *value, + gpointer data, GError **error) +{ + if (value && (*value == 'a' || *value == 'A')) + opts.show_timestamp = SNIFFER_SHOW_TIMESTAMP_ABS; + else + opts.show_timestamp = SNIFFER_SHOW_TIMESTAMP_DELTA; + + return true; +} + +static bool opt_parse_snl_arg(const gchar *option_name, const gchar *value, + gpointer data, GError **error) +{ + gchar *uri; + + opts.snl = true; + + uri = g_strdup(value); + + opts.snl_list = g_slist_prepend(opts.snl_list, uri); + + return true; +} + +static GOptionEntry option_entries[] = { + { "version", 'v', 0, G_OPTION_ARG_NONE, &opts.show_version, + "show version information and exit" }, + { "list", 'l', 0, G_OPTION_ARG_NONE, &opts.list, + "list attached NFC devices", NULL }, + { "device", 'd', 0, G_OPTION_ARG_STRING, &opts.device_name, + "specify a nfc device", "nfcX" }, + { "poll", 'p', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, + opt_parse_poll_arg, "start polling as initiator, target, or both; " + "default mode is initiator", "[Initiator|Target|Both]" }, + { "enable", '1', 0, G_OPTION_ARG_NONE, &opts.enable_dev, + "enable device", NULL }, + { "disable", '0', 0, G_OPTION_ARG_NONE, &opts.disable_dev, + "disable device", NULL }, + { "fw-download", 'w', 0, G_OPTION_ARG_STRING, &opts.fw_filename, + "Put the device in firmware download mode", "fw_filename" }, + { "set-param", 's', 0, G_OPTION_ARG_CALLBACK, opt_parse_set_param_arg, + "set lto, rw, and/or miux parameters", "lto=150,rw=1,miux=100" }, + { "snl", 'k', 0, G_OPTION_ARG_CALLBACK, &opt_parse_snl_arg, + "Send a Service Name Lookup request", "urn:nfc:sn:snep"}, + { "sniff", 'n', 0, G_OPTION_ARG_NONE, &opts.sniff, + "start LLCP sniffer on the specified device", NULL }, + { "snapshot-len", 'a', 0, G_OPTION_ARG_INT, &opts.snap_len, + "packet snapshot length (in bytes); only relevant with -n", "1024" }, + { "dump-symm", 'y', 0, G_OPTION_ARG_NONE, &opts.dump_symm, + "dump SYMM packets to stdout (flooding); only relevant with -n", + NULL }, + { "snep-sap", 'e', 0, G_OPTION_ARG_INT, &opts.snep_sap, + "Specify the sap number to be used for snep decoding; " + "only relevant with -n", "0x04" }, + { "show-timestamp", 't', G_OPTION_FLAG_OPTIONAL_ARG, + G_OPTION_ARG_CALLBACK, opt_parse_show_timestamp_arg, + "show packet timestamp as the delta from first frame (default) " + "or absolute value; only relevant with -n", "[delta|abs]" }, + { "pcap-file", 'f', 0, G_OPTION_ARG_STRING, &opts.pcap_filename, + "specify a filename to save traffic in pcap format; " + "only relevant with -n", "filename" }, + { "push-snep-message", 'm', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, + opt_parse_pushsnepmsg_arg, "push a URI or Text message to a p2p device, " + "default is a URI message", "[URI|Text]" }, + { "vendor_cmd", 'V', 0, G_OPTION_ARG_STRING, &opts.vendor_cmd, + "Send vendor command to driver through NCI or HCI layer", + "\"xx ... xx\"=[OUI][SUBCMD][DATA]"}, + { NULL } +}; + +static int nfctool_options_parse(int argc, char **argv) +{ + GOptionContext *context; + GError *error = NULL; + gchar *start, *end; + int err = -EINVAL; + + context = g_option_context_new("- A small NFC tool box"); + + g_option_context_add_main_entries(context, option_entries, NULL); + + if (!g_option_context_parse(context, &argc, &argv, &error)) { + print_error("%s: %s", argv[0], error->message); + + g_error_free(error); + + goto exit; + } + + if (opts.show_version) { + printf("%s\n", VERSION); + goto done; + } + + if (opts.device_name) { + if (strncmp("nfc", opts.device_name, 3) != 0) { + print_error("Invalid device name: %s", + opts.device_name); + + goto exit; + } + + start = opts.device_name + 3; + + opts.adapter_idx = strtol(start, &end, 10); + if (start == end) { + print_error("Invalid NFC adapter %s", opts.device_name); + + goto exit; + } + } + + if (opts.enable_dev || opts.disable_dev) + opts.list = true; + + if (opts.poll || opts.push_snep_msg) + opts.enable_dev = true; + + opts.need_netlink = opts.list || opts.poll || opts.set_param || + opts.snl || opts.fw_filename || opts.vendor_cmd || + opts.push_snep_msg; + + if (!opts.need_netlink && !opts.sniff) { + printf("%s", g_option_context_get_help(context, TRUE, NULL)); + + goto exit; + } + + if ((opts.poll || opts.set_param || opts.sniff || opts.snl || + opts.enable_dev || opts.disable_dev || opts.fw_filename || + opts.vendor_cmd || opts.push_snep_msg) && + opts.adapter_idx == INVALID_ADAPTER_IDX) { + print_error("Please specify a device with -d nfcX option"); + + goto exit; + } + +done: + err = 0; + +exit: + g_option_context_free(context); + + return err; +} + +static void nfctool_main_loop_start(void) +{ + struct sigaction sa; + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = sig_term; + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + + main_loop = g_main_loop_new(NULL, FALSE); + + g_main_loop_run(main_loop); +} + +static void nfctool_options_cleanup(void) +{ + if (opts.device_name) + g_free(opts.device_name); + + if (opts.pcap_filename) + g_free(opts.pcap_filename); + + if (opts.fw_filename != NULL) + g_free(opts.fw_filename); + + g_slist_free_full(opts.snl_list, g_free); +} + +static void nfctool_main_loop_clean(void) +{ + if (main_loop) + g_main_loop_unref(main_loop); +} + +static void nfctool_quit(bool force) +{ + if (force || (!opts.sniff && !opts.snl)) + g_main_loop_quit(main_loop); + + if (force) + nfctool_set_powered(FALSE); +} + +int main(int argc, char **argv) +{ + int err; + + err = nfctool_options_parse(argc, argv); + if (err) + goto exit_err; + + if (opts.show_version) + goto done; + + adapter_init(); + + if (opts.need_netlink) { + err = nl_init(); + if (err) + goto exit_err; + + err = adapter_all_get_devices(); + if (err) + goto exit_err; + } + + if (opts.fw_filename) { + err = nfctool_fw_download(opts.fw_filename); + if (err) + goto exit_err; + + goto start_loop; + } + + if (opts.sniff) { + err = sniffer_init(); + if (err) + goto exit_err; + } + + if (opts.enable_dev || opts.disable_dev) { + err = nfctool_set_powered(opts.enable_dev); + + if (err && err != -EALREADY) + goto exit_err; + + err = 0; + } + + if (opts.list && !opts.set_param) + adapter_idx_print_info(opts.adapter_idx); + + if (opts.set_param) { + err = nfctool_set_params(); + if (err) + goto exit_err; + } + + if (opts.poll || opts.push_snep_msg) { + err = nfctool_start_poll(); + + if (err == -EBUSY && opts.sniff) + err = 0; + + if (err) + goto exit_err; + } + + if (opts.snl) + nfctool_snl(); + + if (opts.vendor_cmd) { + err = nfctool_send_vendor_cmd(opts.vendor_cmd); + if (err) + goto exit_err; + + goto start_loop; + } + +start_loop: + if (opts.poll || opts.sniff || opts.snl || opts.fw_filename || opts.vendor_cmd || opts.push_snep_msg) + nfctool_main_loop_start(); + +done: + err = 0; + +exit_err: + nfctool_main_loop_clean(); + + adapter_cleanup(); + + nl_cleanup(); + + sniffer_cleanup(); + + nfctool_options_cleanup(); + + if (err) + print_error("%s", strerror(-err)); + + return err; +}
diff --git a/neard/tools/nfctool/ndef-decode.c b/neard/tools/nfctool/ndef-decode.c new file mode 100644 index 0000000..953a622 --- /dev/null +++ b/neard/tools/nfctool/ndef-decode.c
@@ -0,0 +1,378 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <stdio.h> +#include <stdint.h> +#include <glib.h> +#include <errno.h> +#include <string.h> + +#include <near/types.h> + +#include "nfctool.h" +#include "sniffer.h" +#include "ndef-decode.h" + +#define bool_str(b) (b) ? "True" : "False" + +#define ndef_printf_header(fmt, ...) print_indent(NDEF_HEADER_INDENT, \ + NDEF_COLOR, fmt, ## __VA_ARGS__) + +#define ndef_printf_msg(fmt, ...) print_indent(NDEF_MSG_INDENT, NDEF_COLOR, \ + fmt, ## __VA_ARGS__) + +#define ndef_printf_error(fmt, ...) print_indent(NDEF_MSG_INDENT, COLOR_ERROR, \ + fmt, ## __VA_ARGS__) + +#define ndef_printf_buffer(prefix, buf, buf_len) \ +do { \ + int i; \ + printf("%*c%s%s", NDEF_MSG_INDENT, ' ', \ + use_color() ? NDEF_COLOR : "", (prefix)); \ + for (i = 0; i < (buf_len); i++) \ + printf("%02X ", (buf)[i]); \ + printf("\n"); \ +} while(0) + +enum record_tnf { + RECORD_TNF_EMPTY = 0x00, + RECORD_TNF_WELLKNOWN = 0x01, + RECORD_TNF_MIME = 0x02, + RECORD_TNF_URI = 0x03, + RECORD_TNF_EXTERNAL = 0x04, + RECORD_TNF_UNKNOWN = 0x05, + RECORD_TNF_UNCHANGED = 0x06, +}; + +static gchar *tnf_str[] = { + "Empty (0x00)", + "NFC Forum well-known type [NFC RTD] (0x01)", + "Media-type as defined in RFC 2046 [RFC 2046] (0x02)", + "Absolute URI as defined in RFC 3986 [RFC 3986] (0x03)", + "NFC Forum external type [NFC RTD] (0x04)", + "Unknown (0x05)", + "Unchanged (0x06)", + "Reserved (0x07)" +}; + +/* BT EIR list */ +#define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */ +#define EIR_NAME_SHORT 0x08 /* shortened local name */ +#define EIR_NAME_COMPLETE 0x09 /* complete local name */ + +/* Specific OOB EIRs */ +#define EIR_CLASS_OF_DEVICE 0x0D /* class of device */ +#define EIR_SP_HASH 0x0E /* simple pairing hash C */ +#define EIR_SP_RANDOMIZER 0x0F /* simple pairing randomizer R */ +/* Optional EIRs */ +#define EIR_DEVICE_ID 0x10 /* device ID */ +#define EIR_SECURITY_MGR_FLAGS 0x11 /* security manager flags */ + +static void ndef_print_bt_oob(guint8 *oob_data, guint32 oob_length) +{ + guint32 offset = 0; + guint16 length = near_get_le16(oob_data); + guint8 *bdaddr, eir_length, eir_type; + char *local_name; + + if (length != oob_length) { + ndef_printf_error("Malformed Bluetooth OOB data"); + return; + } + + bdaddr = oob_data + 2; + offset = 8; + + ndef_printf_msg("Bluetooth OOB Length: %d", length); + ndef_printf_msg("Bluetooth Address: %x:%x:%x:%x:%x:%x", + bdaddr[5], bdaddr[4], bdaddr[3], + bdaddr[2], bdaddr[1], bdaddr[0]); + + while (offset < length) { + eir_length = oob_data[offset]; + eir_type = oob_data[offset + 1]; + + if (eir_length + offset + 1 > length) + break; + + switch (eir_type) { + case EIR_NAME_SHORT: + case EIR_NAME_COMPLETE: + local_name = g_try_malloc0(eir_length); + if (!local_name) + break; + + g_snprintf(local_name, eir_length, + "%s", oob_data + offset + 2); + + ndef_printf_msg("Bluetooth local name: %s", local_name); + g_free(local_name); + break; + + case EIR_CLASS_OF_DEVICE: + ndef_printf_msg("Bluetooth CoD: 0x%02x-0x%02x-0x%02x", + oob_data[offset + 4], + oob_data[offset + 3], + oob_data[offset + 2]); + break; + + case EIR_SP_HASH: + ndef_printf_buffer("Bluetooth Hash: ", + oob_data + offset + 2, eir_length - 1); + break; + + case EIR_SP_RANDOMIZER: + ndef_printf_buffer("Bluetooth Randomizer: ", + oob_data + offset + 2, eir_length - 1); + break; + + default: + break; + } + + offset += eir_length + 1; + } +} + +#define DE_AUTHENTICATION_TYPE 0x1003 +#define DE_NETWORK_KEY 0x1027 +#define DE_SSID 0x1045 + +static void ndef_print_wsc_oob(guint8 *oob_data, guint32 oob_length) +{ + guint32 offset = 0; + guint16 de_length, de_type; + guint16 auth_type; + char *ssid, *passphrase; + + while (offset < oob_length) { + de_type = near_get_be16(oob_data + offset); + de_length = near_get_be16(oob_data + offset + 2); + + switch(de_type) { + case DE_AUTHENTICATION_TYPE: + auth_type = near_get_be16(oob_data + offset + 4); + ndef_printf_msg("WSC Authentication Type: 0x%02x", + auth_type); + break; + + case DE_SSID: + ssid = g_try_malloc0(de_length + 1); + if (!ssid) + break; + + g_snprintf(ssid, de_length + 1, + "%s", oob_data + offset + 4); + + ndef_printf_msg("SSID: %s", ssid); + g_free(ssid); + break; + + case DE_NETWORK_KEY: + passphrase = g_try_malloc0(de_length + 1); + if (!passphrase) + break; + + g_snprintf(passphrase, de_length + 1, + "%s", oob_data + offset + 4); + + ndef_printf_msg("Passphrase: %s", passphrase); + g_free(passphrase); + break; + + default: + ndef_printf_buffer("Unknown Data Element: ", + oob_data + offset + 4, de_length); + break; + + } + + offset += 4 + de_length; + } +} + +int ndef_print_records(guint8 *data, guint32 data_len) +{ + bool mb, me, cf, sr, il; + enum record_tnf tnf; + char *mime_string; + guint8 type_len; + guint8 *type; + guint32 payload_len; + guint8 *payload; + guint8 id_len; + guint8 *id; + guint32 ndef_offset, record_offset; + guint8 *record; + int err = 0; + +#define CHECK_OFFSET(s) \ + do { \ + if (data_len - (ndef_offset + record_offset) < (s)) { \ + ndef_printf_error("Malformed NDEF record"); \ + sniffer_print_hexdump(stdout, data, data_len, \ + NDEF_HEX_INDENT, TRUE); \ + err = -EINVAL; \ + goto exit; \ + } \ + } while (0) + + ndef_offset = 0; + + while (ndef_offset < data_len) { + + ndef_printf_header("NDEF Record"); + + record = data + ndef_offset; + record_offset = 0; + id_len = 0; + type = NULL; + id = NULL; + payload = NULL; + mime_string = NULL; + + CHECK_OFFSET(2); + + mb = (record[0] & 0x80) != 0; + me = (record[0] & 0x40) != 0; + cf = (record[0] & 0x20) != 0; + sr = (record[0] & 0x10) != 0; + il = (record[0] & 0x08) != 0; + tnf = (record[0] & 0x07); + + type_len = record[1]; + + record_offset += 2; + + if (sr) { + CHECK_OFFSET(1); + + payload_len = record[record_offset]; + + record_offset++; + } else { + CHECK_OFFSET(4); + + memcpy(&payload_len, record + record_offset, 4); + + payload_len = GUINT_FROM_BE(payload_len); + + record_offset += 4; + } + + if (il) { + CHECK_OFFSET(1); + + id_len = record[record_offset]; + + record_offset++; + } + + if (type_len > 0) { + CHECK_OFFSET(type_len); + + type = record + record_offset; + + record_offset += type_len; + } + + if (id_len > 0) { + CHECK_OFFSET(id_len); + + id = record + record_offset; + + record_offset += id_len; + } + + if (payload_len) { + CHECK_OFFSET(payload_len); + + payload = record + record_offset; + + record_offset += payload_len; + } + + ndef_printf_msg("Message Begin: %s", bool_str(mb)); + ndef_printf_msg("Message End: %s", bool_str(me)); + ndef_printf_msg("Chunk Flag: %s", bool_str(cf)); + ndef_printf_msg("Short Record: %s", bool_str(sr)); + ndef_printf_msg("ID Length present: %s", bool_str(il)); + ndef_printf_msg("Type Name Format: %s", tnf_str[tnf]); + ndef_printf_msg("Type Length: %u", type_len); + ndef_printf_msg("Payload Length: %u", payload_len); + + if (il) + ndef_printf_msg("ID Length: %u", id_len); + + if (type) { + switch (tnf) { + case RECORD_TNF_MIME: + mime_string = g_try_malloc(type_len + 1); + if (mime_string) { + g_snprintf(mime_string, + type_len + 1, "%s", type); + + ndef_printf_msg("Type: %s", mime_string); + break; + } + + default: + ndef_printf_msg("Type:"); + sniffer_print_hexdump(stdout, type, type_len, + NDEF_HEX_INDENT, FALSE); + + break; + } + } + + if (id) { + ndef_printf_msg("ID:"); + + sniffer_print_hexdump(stdout, id, id_len, + NDEF_HEX_INDENT, FALSE); + } + + if (payload) { + if (mime_string) { + if (strcmp(mime_string, + "application/vnd.bluetooth.ep.oob") == 0) + ndef_print_bt_oob(payload, payload_len); + else if (strcmp(mime_string, + "application/vnd.wfa.wsc") == 0) + ndef_print_wsc_oob(payload, payload_len); + + g_free(mime_string); + } else { + ndef_printf_msg("Payload:"); + + sniffer_print_hexdump(stdout, payload, + payload_len, NDEF_HEX_INDENT, FALSE); + } + } + + ndef_offset += record_offset; + } + +exit: + return err; + +#undef CHECK_OFFSET +}
diff --git a/neard/tools/nfctool/ndef-decode.h b/neard/tools/nfctool/ndef-decode.h new file mode 100644 index 0000000..5ef8b84 --- /dev/null +++ b/neard/tools/nfctool/ndef-decode.h
@@ -0,0 +1,26 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef __NDEF_DECODE_H +#define __NDEF_DECODE_H + +int ndef_print_records(guint8 *data, guint32 data_len); + +#endif /* __NDEF_DECODE_H */
diff --git a/neard/tools/nfctool/netlink.c b/neard/tools/nfctool/netlink.c new file mode 100644 index 0000000..690fdfa --- /dev/null +++ b/neard/tools/nfctool/netlink.c
@@ -0,0 +1,961 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <errno.h> +#include <sys/socket.h> + +#include <netlink/netlink.h> +#include <netlink/genl/genl.h> +#include <netlink/genl/family.h> +#include <netlink/genl/ctrl.h> + +#include <glib.h> + +#include <near/nfc_copy.h> + +#include "nfctool.h" +#include "netlink.h" +#include "adapter.h" + +#ifdef NEED_LIBNL_COMPAT +#define nl_sock nl_handle + +static inline struct nl_handle *nl_socket_alloc(void) +{ + return nl_handle_alloc(); +} + +static inline void nl_socket_free(struct nl_sock *h) +{ + nl_handle_destroy(h); +} + +#define NLE_MISSING_ATTR 14 + +static inline void __nl_perror(int error, const char *s) +{ + nl_perror(s); +} +#define nl_perror __nl_perror +#endif + +struct handler_args { + const char *group; + int id; +}; + +struct nlnfc_state { + struct nl_sock *cmd_sock; + struct nl_sock *event_sock; + int nfc_id; + int mcid; +}; + +static struct nlnfc_state *nfc_state = NULL; + +static GIOChannel *nl_gio_channel = NULL; + +static GHashTable *handlers = NULL; + +static int nl_error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, + void *arg) +{ + int *ret = arg; + + DBG(""); + + *ret = err->error; + + return NL_STOP; +} + +static int nl_finish_handler(struct nl_msg *msg, void *arg) +{ + int *ret = arg; + + DBG(""); + + *ret = 1; + + return NL_SKIP; +} + +static int nl_ack_handler(struct nl_msg *msg, void *arg) +{ + int *ret = arg; + + DBG(""); + + *ret = 1; + + return NL_STOP; +} + +static int nl_send_msg(struct nl_sock *sock, struct nl_msg *msg, + int (*rx_handler)(struct nl_msg *, void *), + void *data) +{ + struct nl_cb *cb; + int err, done; + + DBG(""); + + cb = nl_cb_alloc(NL_CB_DEFAULT); + if (!cb) + return -ENOMEM; + + err = nl_send_auto_complete(sock, msg); + if (err < 0) { + nl_cb_put(cb); + print_error("%s", strerror(err)); + + return err; + } + + err = done = 0; + + nl_cb_err(cb, NL_CB_CUSTOM, nl_error_handler, &err); + nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, nl_finish_handler, &done); + nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, nl_ack_handler, &done); + + if (rx_handler) + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, rx_handler, data); + + while (err == 0 && done == 0) + nl_recvmsgs(sock, cb); + + nl_cb_put(cb); + + return err; +} + +static int nl_family_handler(struct nl_msg *msg, void *arg) +{ + struct handler_args *grp = arg; + struct nlattr *tb[CTRL_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *mcgrp; + int rem_mcgrp; + + DBG(""); + + nla_parse(tb, CTRL_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (!tb[CTRL_ATTR_MCAST_GROUPS]) + return NL_SKIP; + + nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], rem_mcgrp) { + struct nlattr *tb_mcgrp[CTRL_ATTR_MCAST_GRP_MAX + 1]; + + nla_parse(tb_mcgrp, CTRL_ATTR_MCAST_GRP_MAX, + nla_data(mcgrp), nla_len(mcgrp), NULL); + + if (!tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME] || + !tb_mcgrp[CTRL_ATTR_MCAST_GRP_ID]) + continue; + if (strncmp(nla_data(tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME]), + grp->group, + nla_len(tb_mcgrp[CTRL_ATTR_MCAST_GRP_NAME]))) + continue; + grp->id = nla_get_u32(tb_mcgrp[CTRL_ATTR_MCAST_GRP_ID]); + break; + } + + return NL_SKIP; +} + +static int nl_get_multicast_id(struct nl_sock *sock, const char *family, + const char *group) +{ + struct nl_msg *msg; + int err = 0, ctrlid; + struct handler_args grp = { + .group = group, + .id = -ENOENT, + }; + + DBG(""); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + ctrlid = genl_ctrl_resolve(sock, "nlctrl"); + + genlmsg_put(msg, 0, 0, ctrlid, 0, + 0, CTRL_CMD_GETFAMILY, 0); + + NLA_PUT_STRING(msg, CTRL_ATTR_FAMILY_NAME, family); + + err = nl_send_msg(sock, msg, nl_family_handler, &grp); + if (err) + goto nla_put_failure; + + DBG("multicast id %d", grp.id); + + err = grp.id; + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static int nl_no_seq_check_cb(struct nl_msg *n, void *arg) +{ + DBG(""); + + return NL_OK; +} + +static int nl_get_params_handler(struct nl_msg *n, void *arg) +{ + struct nlmsghdr *nlh = nlmsg_hdr(n); + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + struct nfc_adapter *adapter = (struct nfc_adapter *)arg; + guint32 idx; + + DBG(""); + + genlmsg_parse(nlh, 0, attrs, NFC_ATTR_MAX, NULL); + + if (!attrs[NFC_ATTR_DEVICE_INDEX]) { + nl_perror(NLE_MISSING_ATTR, "NFC_CMD_GET_PARAMS"); + return NL_STOP; + } + + idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + if (idx != adapter->idx) { + nl_perror(NLE_MISSING_ATTR, "NFC_CMD_GET_PARAMS"); + return NL_STOP; + } + + adapter->param_lto = nla_get_u8(attrs[NFC_ATTR_LLC_PARAM_LTO]); + adapter->param_rw = nla_get_u8(attrs[NFC_ATTR_LLC_PARAM_RW]); + adapter->param_miux = nla_get_u16(attrs[NFC_ATTR_LLC_PARAM_MIUX]); + + return NL_STOP; +} + +int nl_get_params(struct nfc_adapter *adapter) +{ + struct nl_msg *msg; + void *hdr; + int err = 0; + + DBG(""); + + if (!nfc_state || nfc_state->nfc_id < 0) + return -ENODEV; + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + 0, NFC_CMD_LLC_GET_PARAMS, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, adapter->idx); + + err = nl_send_msg(nfc_state->cmd_sock, msg, nl_get_params_handler, + adapter); + + DBG("nl_send_msg returns %d", err); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int nl_set_params(struct nfc_adapter *adapter, gint32 lto, gint32 rw, + gint32 miux) +{ + struct nl_msg *msg; + void *hdr; + int err = 0; + + DBG(""); + + if (lto < 0 && rw < 0 && miux < 0) + return -EINVAL; + + if (!nfc_state || nfc_state->nfc_id < 0) + return -ENODEV; + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + 0, NFC_CMD_LLC_SET_PARAMS, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, adapter->idx); + if (lto >= 0) + NLA_PUT_U8(msg, NFC_ATTR_LLC_PARAM_LTO, (guint8)lto); + if (rw >= 0) + NLA_PUT_U8(msg, NFC_ATTR_LLC_PARAM_RW, (guint8)rw); + if (miux >= 0) + NLA_PUT_U16(msg, NFC_ATTR_LLC_PARAM_MIUX, (guint16)miux); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + + DBG("nl_send_msg returns %d", err); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static int nl_get_targets_handler(struct nl_msg *n, void *arg) +{ + struct nlmsghdr *nlh = nlmsg_hdr(n); + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + guint32 target_idx, target_type, protocols; + struct nfc_adapter *adapter; + + DBG(""); + + adapter = (struct nfc_adapter *)arg; + + genlmsg_parse(nlh, 0, attrs, NFC_ATTR_MAX, NULL); + + target_idx = nla_get_u32(attrs[NFC_ATTR_TARGET_INDEX]); + protocols = nla_get_u32(attrs[NFC_ATTR_PROTOCOLS]); + + if (protocols & NFC_PROTO_NFC_DEP_MASK) + target_type = TARGET_TYPE_DEVICE; + else + target_type = TARGET_TYPE_TAG; + + adapter_add_target(adapter, target_type, target_idx); + + return 0; +} + +int nl_get_targets(struct nfc_adapter *adapter) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + if (!nfc_state || nfc_state->nfc_id < 0) + return -ENODEV; + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_DUMP, NFC_CMD_GET_TARGET, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + g_slist_free(adapter->tags); + adapter->tags = NULL; + + g_slist_free(adapter->devices); + adapter->devices = NULL; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, adapter->idx); + + err = nl_send_msg(nfc_state->cmd_sock, msg, + nl_get_targets_handler, adapter); + + DBG("nl_send_msg returns %d", err); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static int nl_get_devices_handler(struct nl_msg *n, void *arg) +{ + struct nlmsghdr *nlh = nlmsg_hdr(n); + struct nlattr *attrs[NFC_ATTR_MAX + 1]; + guint32 idx, protocols = 0; + guint8 powered = 0; + guint8 rf_mode = NFC_RF_NONE; + + DBG(""); + + genlmsg_parse(nlh, 0, attrs, NFC_ATTR_MAX, NULL); + + if (!attrs[NFC_ATTR_DEVICE_INDEX]) { + nl_perror(NLE_MISSING_ATTR, "NFC_CMD_GET_DEVICE"); + return NL_STOP; + } + + idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]); + + if (attrs[NFC_ATTR_PROTOCOLS]) + protocols = nla_get_u32(attrs[NFC_ATTR_PROTOCOLS]); + + if (attrs[NFC_ATTR_RF_MODE]) + rf_mode = nla_get_u8(attrs[NFC_ATTR_RF_MODE]); + + if (attrs[NFC_ATTR_DEVICE_POWERED]) + powered = nla_get_u8(attrs[NFC_ATTR_DEVICE_POWERED]); + + adapter_add(idx, protocols, powered, rf_mode); + + return NL_SKIP; +} + +int nl_get_devices(void) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + if (!nfc_state || nfc_state->nfc_id < 0) + return -ENODEV; + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_DUMP, NFC_CMD_GET_DEVICE, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto out; + } + + err = nl_send_msg(nfc_state->cmd_sock, msg, nl_get_devices_handler, + NULL); + + DBG("nl_send_msg returns %d", err); + +out: + nlmsg_free(msg); + + return err; +} + +int nl_send_dep_link_up(guint32 idx, guint32 target_idx) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_DEP_LINK_UP, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx); + NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target_idx); + NLA_PUT_U8(msg, NFC_ATTR_COMM_MODE, NFC_COMM_ACTIVE); + NLA_PUT_U8(msg, NFC_ATTR_RF_MODE, NFC_RF_INITIATOR); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int nl_start_poll(struct nfc_adapter *adapter, guint8 mode) +{ + struct nl_msg *msg; + void *hdr; + int err; + guint32 im_protocols = 0; + guint32 tm_protocols = 0; + + if ((mode & POLLING_MODE_INITIATOR) == POLLING_MODE_INITIATOR) + im_protocols = adapter->protocols; + + if ((mode & POLLING_MODE_TARGET) == POLLING_MODE_TARGET) + tm_protocols = adapter->protocols; + + DBG("IM protos 0x%x TM protos 0x%x", im_protocols, tm_protocols); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_START_POLL, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, adapter->idx); + if (im_protocols != 0) { + NLA_PUT_U32(msg, NFC_ATTR_IM_PROTOCOLS, im_protocols); + NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, im_protocols); + } + if (tm_protocols != 0) + NLA_PUT_U32(msg, NFC_ATTR_TM_PROTOCOLS, tm_protocols); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + + if (err == 0) + adapter->polling = TRUE; + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int nl_set_powered(struct nfc_adapter *adapter, bool powered) +{ + struct nl_msg *msg; + void *hdr; + int err; + uint8_t cmd; + + DBG(""); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + if (powered) + cmd = NFC_CMD_DEV_UP; + else + cmd = NFC_CMD_DEV_DOWN; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, cmd, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, adapter->idx); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int nl_send_sdreq(struct nfc_adapter *adapter, GSList *uris) +{ + struct nl_msg *msg; + void *hdr; + GSList *uri; + struct nlattr *sdp_attr, *uri_attr; + int err = 0, i; + + DBG(""); + + if (!nfc_state || nfc_state->nfc_id < 0) + return -ENODEV; + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_LLC_SDREQ, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, adapter->idx); + + sdp_attr = nla_nest_start(msg, NFC_ATTR_LLC_SDP); + if (!sdp_attr) { + err = -ENOMEM; + goto nla_put_failure; + } + + i = 1; + uri = uris; + while (uri) { + uri_attr = nla_nest_start(msg, i); + + if (!uri_attr) { + err = -ENOMEM; + goto nla_put_failure; + } + + NLA_PUT_STRING(msg, NFC_SDP_ATTR_URI, uri->data); + + nla_nest_end(msg, uri_attr); + + uri = g_slist_next(uri); + + i++; + } + + nla_nest_end(msg, sdp_attr); + + err = nl_send_msg(nfc_state->event_sock, msg, NULL, NULL); + + DBG("nl_send_msg returns %d", err); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static int nl_nfc_send_sdres_event(guint32 idx, struct nlattr *sdres_attr, + nfc_event_cb_t handler) +{ + GSList *sdres_list = NULL; + struct nfc_snl *sdres; + struct nlattr *attr; + struct nlattr *sdp_attrs[NFC_SDP_ATTR_MAX + 1]; + int rem, err = 0; + size_t uri_len; + + nla_for_each_nested(attr, sdres_attr, rem) { + err = nla_parse_nested(sdp_attrs, NFC_SDP_ATTR_MAX, + attr, NULL); + + if (err != 0) { + DBG("nla_parse_nested returned %d\n", err); + continue; + } + + if (!sdp_attrs[NFC_SDP_ATTR_URI] || + !sdp_attrs[NFC_SDP_ATTR_SAP]) { + print_error("Missing attribute in reply"); + continue; + } + + uri_len = nla_strlcpy(NULL, sdp_attrs[NFC_SDP_ATTR_URI], 0); + + uri_len++; + + sdres = nfctool_snl_alloc(uri_len); + + nla_strlcpy(sdres->uri, sdp_attrs[NFC_SDP_ATTR_URI], uri_len); + + sdres->sap = nla_get_u8(sdp_attrs[NFC_SDP_ATTR_SAP]); + + DBG("URI: %s, sap: %d\n", sdres->uri, sdres->sap); + + sdres_list = g_slist_append(sdres_list, sdres); + } + + handler(NFC_EVENT_LLC_SDRES, idx, sdres_list); + + g_slist_free_full(sdres_list, (GDestroyNotify)nfctool_sdres_free); + + return err; +} + +int nl_fw_download(struct nfc_adapter *adapter, gchar *fw_filename) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + if (nfc_state == NULL || nfc_state->nfc_id < 0) + return -ENODEV; + + msg = nlmsg_alloc(); + if (msg == NULL) + return -ENOMEM; + + err = -EINVAL; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_FW_DOWNLOAD, NFC_GENL_VERSION); + if (hdr == NULL) + goto nla_put_failure; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, adapter->idx); + + NLA_PUT_STRING(msg, NFC_ATTR_FIRMWARE_NAME, fw_filename); + + err = nl_send_msg(nfc_state->event_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +int nl_send_vendor_cmd(struct nfc_adapter *adapter, guint32 oui, guint32 sub_cmd, + guint32 data_len, guint8 *data) +{ + struct nl_msg *msg; + struct nl_data *nl_data_buffer; + void *hdr; + int err; + + DBG("oui 0x%08x sub_cmd 0x%08x data_len %ld", oui, sub_cmd, data_len); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_VENDOR, NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, adapter->idx); + NLA_PUT_U32(msg, NFC_ATTR_VENDOR_ID, oui); + NLA_PUT_U32(msg, NFC_ATTR_VENDOR_SUBCMD, sub_cmd); + + if (data_len > 0) { + nl_data_buffer = nl_data_alloc(data, data_len); + if (!nl_data_buffer) { + err = -ENOMEM; + goto nla_put_failure; + } + err = nla_put_data(msg, NFC_ATTR_VENDOR_DATA, nl_data_buffer); + } else { + nl_data_buffer = NULL; + err = nla_put(msg, NFC_ATTR_VENDOR_DATA, 0, NULL); + } + if (err < 0) + goto nla_fail_free_data; + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_fail_free_data: + if (nl_data_buffer) + nl_data_free(nl_data_buffer); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + +static int nl_nfc_event_cb(struct nl_msg *n, void *arg) +{ + guint32 idx = INVALID_ADAPTER_IDX; + struct nlattr *attr[NFC_ATTR_MAX + 1]; + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(n)); + guint32 cmd = gnlh->cmd; + nfc_event_cb_t cb = NULL; + + DBG("Received cmd %d", gnlh->cmd); + + nla_parse(attr, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + if (attr[NFC_ATTR_DEVICE_INDEX]) + idx = nla_get_u32(attr[NFC_ATTR_DEVICE_INDEX]); + + if (handlers) + cb = g_hash_table_lookup(handlers, GINT_TO_POINTER(cmd)); + + if (!cb) + return NL_SKIP; + + switch (cmd) { + case NFC_EVENT_LLC_SDRES: + DBG("Received NFC_EVENT_LLC_SDRES\n"); + nl_nfc_send_sdres_event(idx, attr[NFC_ATTR_LLC_SDP], cb); + break; + + default: + cb(gnlh->cmd, idx, &attr); + break; + } + + return NL_SKIP; +} + +static gboolean nl_gio_handler(GIOChannel *channel, + GIOCondition cond, gpointer data) +{ + struct nl_cb *cb; + struct nlnfc_state *state = data; + + if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) + return FALSE; + + cb = nl_cb_alloc(NL_CB_VERBOSE); + if (!cb) + return TRUE; + + nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, nl_no_seq_check_cb, NULL); + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, nl_nfc_event_cb, data); + + nl_recvmsgs(state->event_sock, cb); + + nl_cb_put(cb); + + return TRUE; +} + +void nl_add_event_handler(guint8 cmd, nfc_event_cb_t cb) +{ + guint32 c = cmd; + + if (handlers) + g_hash_table_replace(handlers, GINT_TO_POINTER(c), cb); +} + +void nl_cleanup(void) +{ + if (nl_gio_channel) { + g_io_channel_shutdown(nl_gio_channel, TRUE, NULL); + g_io_channel_unref(nl_gio_channel); + nl_gio_channel = NULL; + } + + if (nfc_state) { + if (nfc_state->cmd_sock) + nl_socket_free(nfc_state->cmd_sock); + + if (nfc_state->event_sock) + nl_socket_free(nfc_state->event_sock); + + g_free(nfc_state); + nfc_state = NULL; + } + + if (handlers) + g_hash_table_destroy(handlers); +} + +int nl_init(void) +{ + int err; + int fd; + + DBG(""); + + nfc_state = g_malloc0(sizeof(struct nlnfc_state)); + + nfc_state->cmd_sock = nl_socket_alloc(); + if (!nfc_state->cmd_sock) { + print_error("Failed to allocate NFC netlink socket"); + err = -ENOMEM; + goto exit_err; + } + + nfc_state->event_sock = nl_socket_alloc(); + if (!nfc_state->event_sock) { + print_error("Failed to allocate NFC netlink socket"); + err = -ENOMEM; + goto exit_err; + } + + if (genl_connect(nfc_state->cmd_sock)) { + print_error("Failed to connect to generic netlink"); + err = -ENOLINK; + goto exit_err; + } + + if (genl_connect(nfc_state->event_sock)) { + print_error("Failed to connect to generic netlink"); + err = -ENOLINK; + goto exit_err; + } + + nfc_state->nfc_id = genl_ctrl_resolve(nfc_state->cmd_sock, "nfc"); + if (nfc_state->nfc_id < 0) { + print_error("Unable to find NFC netlink family"); + err = -ENOENT; + goto exit_err; + } + + nfc_state->mcid = nl_get_multicast_id(nfc_state->cmd_sock, + NFC_GENL_NAME, + NFC_GENL_MCAST_EVENT_NAME); + if (nfc_state->mcid <= 0) { + print_error("Wrong mcast id %d", nfc_state->mcid); + err = nfc_state->mcid; + goto exit_err; + } + + err = nl_socket_add_membership(nfc_state->event_sock, nfc_state->mcid); + if (err) { + print_error("Error adding nl socket to membership"); + goto exit_err; + } + + handlers = g_hash_table_new(g_direct_hash, g_direct_equal); + + fd = nl_socket_get_fd(nfc_state->event_sock); + nl_gio_channel = g_io_channel_unix_new(fd); + g_io_channel_set_close_on_unref(nl_gio_channel, TRUE); + + g_io_channel_set_encoding(nl_gio_channel, NULL, NULL); + g_io_channel_set_buffered(nl_gio_channel, FALSE); + + g_io_add_watch(nl_gio_channel, + G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR, + nl_gio_handler, nfc_state); + + return 0; + +exit_err: + nl_cleanup(); + + print_error("netlink init failed"); + + return err; +}
diff --git a/neard/tools/nfctool/netlink.h b/neard/tools/nfctool/netlink.h new file mode 100644 index 0000000..01c5e47 --- /dev/null +++ b/neard/tools/nfctool/netlink.h
@@ -0,0 +1,56 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef __NETLINK_H +#define __NETLINK_H + +typedef int (*nfc_event_cb_t)(guint8 cmd, guint32 adapter_idx, gpointer data); + +struct nfc_adapter; + +int nl_init(void); + +void nl_cleanup(void); + +void nl_add_event_handler(guint8 cmd, nfc_event_cb_t cb); + +int nl_get_devices(void); + +int nl_get_targets(struct nfc_adapter *adapter); + +int nl_send_dep_link_up(guint32 idx, guint32 target_idx); + +int nl_start_poll(struct nfc_adapter *adapter, guint8 mode); + +int nl_set_params(struct nfc_adapter *adapter, gint32 lto, gint32 rw, + gint32 miux); + +int nl_get_params(struct nfc_adapter *adapter); + +int nl_send_sdreq(struct nfc_adapter *adapter, GSList *uris); + +int nl_set_powered(struct nfc_adapter *adapter, bool powered); + +int nl_fw_download(struct nfc_adapter *adapter, gchar *fw_filename); + +int nl_send_vendor_cmd(struct nfc_adapter *adapter, guint32 oui, guint32 sub_cmd, + guint32 data_len, guint8 *data); + +#endif /* __NETLINK_H */
diff --git a/neard/tools/nfctool/nfctool.h b/neard/tools/nfctool/nfctool.h new file mode 100644 index 0000000..ecd1f4e --- /dev/null +++ b/neard/tools/nfctool/nfctool.h
@@ -0,0 +1,103 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __NFCTOOL_H +#define __NFCTOOL_H + +#include "display.h" + +#ifdef DEBUG +#define DBG(fmt, ...) fprintf(stdout, "%s: " fmt "\n", __func__, ## __VA_ARGS__) +#else +#define DBG(fmt, ...) +#endif + +#define LLCP_COLOR COLOR_CYAN +#define LLCP_HEADER_INDENT 0 +#define LLCP_MSG_INDENT 4 + +#define SNEP_COLOR COLOR_YELLOW +#define SNEP_HEADER_INDENT 4 +#define SNEP_MSG_INDENT 6 + +#define NDEF_COLOR COLOR_BLUE +#define NDEF_HEADER_INDENT 6 +#define NDEF_MSG_INDENT 8 +#define NDEF_HEX_INDENT 9 + +#define print_error(fmt, ...) fprintf(stderr, fmt"\n", ## __VA_ARGS__) + +#define POLLING_MODE_INITIATOR 0x01 +#define POLLING_MODE_TARGET 0x02 +#define POLLING_MODE_BOTH 0x03 + +#define INVALID_ADAPTER_IDX 0xFFFFFFFF + +#define TARGET_TYPE_TAG 0 +#define TARGET_TYPE_DEVICE 1 + +#define SNIFFER_SHOW_TIMESTAMP_NONE 0 +#define SNIFFER_SHOW_TIMESTAMP_DELTA 1 +#define SNIFFER_SHOW_TIMESTAMP_ABS 2 + +struct nfctool_options { + gboolean show_version; + gboolean list; + gboolean poll; + guint8 poll_mode; + gchar *device_name; + guint32 adapter_idx; + gboolean enable_dev; + gboolean disable_dev; + gchar *fw_filename; + gboolean set_param; + gint32 lto; + gint32 rw; + gint32 miux; + gboolean need_netlink; + gboolean snl; + GSList *snl_list; + gboolean sniff; + gsize snap_len; + gboolean dump_symm; + guint8 show_timestamp; + guint8 snep_sap; + guint8 handover_sap; + gchar *pcap_filename; + gchar *vendor_cmd; + gboolean push_snep_msg; + gboolean push_snep_uri; +}; + +struct nfc_snl { + gchar *uri; + gsize uri_size; + guint8 sap; +}; + +struct nfc_snl *nfctool_snl_alloc(gsize uri_size); + +void nfctool_sdres_free(struct nfc_snl *snl); + +extern struct nfctool_options opts; + + +#endif /* __NFCTOOL_H */
diff --git a/neard/tools/nfctool/snep-decode.c b/neard/tools/nfctool/snep-decode.c new file mode 100644 index 0000000..bee06e5 --- /dev/null +++ b/neard/tools/nfctool/snep-decode.c
@@ -0,0 +1,380 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#include <stdio.h> +#include <glib.h> +#include <errno.h> +#include <string.h> +#include <netdb.h> +#include <sys/time.h> + +#include <near/nfc_copy.h> + +#include "nfctool.h" +#include "sniffer.h" +#include "ndef-decode.h" +#include "snep-decode.h" + +#define SNEP_HEADER_LEN 6 + +#define SNEP_REQUEST_CONTINUE 0x00 +#define SNEP_REQUEST_GET 0x01 +#define SNEP_REQUEST_PUT 0x02 +#define SNEP_REQUEST_REJECT 0x7f + +#define SNEP_RESPONSE_CONTINUE 0x80 +#define SNEP_RESPONSE_SUCCESS 0x81 +#define SNEP_RESPONSE_NOT_FOUND 0xc0 +#define SNEP_RESPONSE_EXCESS_DATA 0xc1 +#define SNEP_RESPONSE_BAD_REQUEST 0xc2 +#define SNEP_RESPONSE_NOT_IMPLEMENTED 0xe0 +#define SNEP_RESPONSE_UNSUPPORTED 0xe1 +#define SNEP_RESPONSE_REJECT 0xff + +#define snep_make_frag_index(idx, dir, lsap, rsap) \ + ((((idx) << 24) & 0xFF000000) | \ + (((dir) << 16) & 0x00FF0000) | \ + (((lsap) << 8) & 0x0000FF00) | \ + ((rsap) & 0x000000FF)) + +#define snep_get_frag_index(p) \ + snep_make_frag_index((p)->adapter_idx, (p)->direction, \ + (p)->llcp.local_sap, (p)->llcp.remote_sap) + +#define snep_printf_header(fmt, ...) print_indent(SNEP_HEADER_INDENT, \ + SNEP_COLOR, fmt, ## __VA_ARGS__) + +#define snep_printf_msg(fmt, ...) print_indent(SNEP_MSG_INDENT, \ + SNEP_COLOR, fmt, ## __VA_ARGS__) + +#define snep_printf_error(fmt, ...) print_indent(SNEP_MSG_INDENT, COLOR_ERROR, \ + fmt, ## __VA_ARGS__) + +struct snep_frag { + guint32 index; + guint16 count; + guint32 received; + guint32 buffer_size; + guint8 *buffer; +}; + +static GHashTable *snep_frag_hash = NULL; + +static void snep_frag_free(struct snep_frag *frag) +{ + g_free(frag->buffer); + g_free(frag); +} + +static void snep_frag_delete(guint32 frag_index) +{ + DBG("Deleting frag with index 0x%x", frag_index); + + g_hash_table_remove(snep_frag_hash, GINT_TO_POINTER(frag_index)); +} + +static void snep_frag_rejected(struct sniffer_packet *packet) +{ + guint32 index; + guint8 direction; + + /* reverse direction to delete the corresponding fragment */ + if (packet->direction == NFC_LLCP_DIRECTION_RX) + direction = NFC_LLCP_DIRECTION_TX; + else + direction = NFC_LLCP_DIRECTION_RX; + + index = snep_make_frag_index(packet->adapter_idx, + direction, + packet->llcp.local_sap, + packet->llcp.remote_sap); + + snep_frag_delete(index); +} + +static int snep_frag_append(struct snep_frag *frag, + struct sniffer_packet *packet) +{ + int err = 0; + + snep_printf_msg("Ongoing fragmented message"); + + if (frag->received + packet->llcp.data_len > frag->buffer_size) { + snep_printf_error("Too many bytes received"); + return -EINVAL; + } + + memcpy(frag->buffer + frag->received, packet->llcp.data, + packet->llcp.data_len); + + frag->received += packet->llcp.data_len; + + frag->count++; + + snep_printf_msg("%s fragment #%hu of %u bytes (total %u/%u)", + packet->direction == NFC_LLCP_DIRECTION_RX ? "Received" : "Sent", + frag->count, packet->llcp.data_len, + frag->received, frag->buffer_size); + + if (frag->received == frag->buffer_size) { + snep_printf_msg("End of fragmented message"); + + err = ndef_print_records(packet->snep.data, + packet->snep.data_len); + + snep_frag_delete(frag->index); + } + + return err; +} + +static int snep_decode_info(struct sniffer_packet *packet) +{ + struct snep_frag *frag; + int err; + + if (packet->snep.data_len <= packet->snep.real_len) { + /* Message is not fragmented */ + err = ndef_print_records(packet->snep.data, + packet->snep.data_len); + + return err; + } + + frag = g_malloc(sizeof(struct snep_frag)); + if (!frag) + return -ENOMEM; + + frag->count = 1; + + frag->buffer_size = packet->snep.data_len; + + frag->received = packet->snep.real_len; + + frag->buffer = g_malloc0(frag->buffer_size); + if (!frag->buffer) + return -ENOMEM; + + memcpy(frag->buffer, packet->snep.data, packet->snep.real_len); + + frag->index = snep_get_frag_index(packet); + + snep_printf_msg("Start %s fragmented message of %u bytes", + packet->direction == NFC_LLCP_DIRECTION_RX ? "Receiving" : "Sending", + frag->buffer_size); + + snep_printf_msg("%s fragment #%hu of %u bytes", + packet->direction == NFC_LLCP_DIRECTION_RX ? "Received" : "Sent", + frag->count, frag->received); + + DBG("Adding frag with index 0x%x", frag->index); + + g_hash_table_replace(snep_frag_hash, GINT_TO_POINTER(frag->index), + frag); + + return 0; +} + +static int snep_decode_req_get(struct sniffer_packet *packet) +{ + guint32 acceptable_len; + + if (packet->snep.real_len < 4) + return -EINVAL; + + memcpy(&acceptable_len, packet->snep.data, 4); + packet->snep.acceptable_len = GUINT_FROM_BE(acceptable_len); + + packet->snep.data += 4; + packet->snep.data_len -= 4; + packet->snep.real_len -= 4; + + return 0; +} + +static int snep_decode_header(struct sniffer_packet *packet) +{ + guint32 data_len; + guint8 *data = packet->llcp.data; + + if (packet->llcp.data_len < SNEP_HEADER_LEN) + return -EINVAL; + + packet->snep.version = data[0]; + + packet->snep.rcode = data[1]; + + memcpy(&data_len, data + 2, 4); + + packet->snep.data_len = GUINT_FROM_BE(data_len); + + packet->snep.real_len = packet->llcp.data_len - SNEP_HEADER_LEN; + + if (packet->snep.data_len != 0) + packet->snep.data = data + SNEP_HEADER_LEN; + + return 0; +} + +static void snep_print_version(struct sniffer_packet *packet) +{ + snep_printf_msg("Version: %d.%d", (packet->snep.version & 0xF0) >> 4, + packet->snep.version & 0x0F); +} + +static void print_request(struct sniffer_packet *packet, gchar *msg) +{ + snep_print_version(packet); + + snep_printf_msg("Request: %s", msg); +} + +static void snep_print_response(struct sniffer_packet *packet, gchar *msg) +{ + snep_print_version(packet); + + snep_printf_msg("Response: %s", msg); +} + +int snep_print_pdu(struct sniffer_packet *packet) +{ + int err = 0; + guint32 frag_index; + struct snep_frag *frag; + + snep_printf_header("Simple NDEF Exchange Protocol (SNEP)"); + + frag_index = snep_get_frag_index(packet); + + frag = g_hash_table_lookup(snep_frag_hash, GINT_TO_POINTER(frag_index)); + + if (frag) { + /* Incoming or outgoing fragmented message */ + err = snep_frag_append(frag, packet); + + if (err != 0) { + snep_printf_error("Error receiving fragmented message"); + + snep_frag_delete(frag_index); + } + + goto exit; + } + + err = snep_decode_header(packet); + if (err != 0) { + snep_printf_error("Error decoding message header"); + + goto exit; + } + + switch (packet->snep.rcode) { + /* Requests */ + case SNEP_REQUEST_CONTINUE: + print_request(packet, "Continue"); + break; + + case SNEP_REQUEST_GET: + print_request(packet, "Get"); + + err = snep_decode_req_get(packet); + if (err != 0) + goto exit; + + snep_printf_msg("Acceptable length: %u", + packet->snep.acceptable_len); + + snep_decode_info(packet); + break; + + case SNEP_REQUEST_PUT: + print_request(packet, "Put"); + + snep_decode_info(packet); + break; + + case SNEP_REQUEST_REJECT: + print_request(packet, "Reject"); + + snep_frag_rejected(packet); + break; + + /* Responses */ + case SNEP_RESPONSE_CONTINUE: + snep_print_response(packet, "Continue"); + break; + + case SNEP_RESPONSE_SUCCESS: + snep_print_response(packet, "Success"); + + if (packet->snep.data_len > 0) + snep_decode_info(packet); + break; + + case SNEP_RESPONSE_NOT_FOUND: + snep_print_response(packet, "Not Found"); + break; + + case SNEP_RESPONSE_EXCESS_DATA: + snep_print_response(packet, "Excess Data"); + break; + + case SNEP_RESPONSE_BAD_REQUEST: + snep_print_response(packet, "Bad Request"); + break; + + case SNEP_RESPONSE_NOT_IMPLEMENTED: + snep_print_response(packet, "Not Implemented"); + break; + + case SNEP_RESPONSE_UNSUPPORTED: + snep_print_response(packet, "Unsupported"); + break; + + case SNEP_RESPONSE_REJECT: + snep_print_response(packet, "Reject"); + + snep_frag_rejected(packet); + break; + + default: + snep_printf_error("Invalid request or response code: %d", + packet->snep.rcode); + break; + } + +exit: + return err; +} + +void snep_decode_cleanup(void) +{ + if (snep_frag_hash) + g_hash_table_destroy(snep_frag_hash); +} + +int snep_decode_init(void) +{ + snep_frag_hash = + g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, + (GDestroyNotify)snep_frag_free); + + return 0; +}
diff --git a/neard/tools/nfctool/snep-decode.h b/neard/tools/nfctool/snep-decode.h new file mode 100644 index 0000000..352ca7c --- /dev/null +++ b/neard/tools/nfctool/snep-decode.h
@@ -0,0 +1,30 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef __SNEP_DECODE_H +#define __SNEP_DECODE_H + +int snep_decode_init(void); + +void snep_decode_cleanup(void); + +int snep_print_pdu(struct sniffer_packet *packet); + +#endif /* __SNEP_DECODE_H */
diff --git a/neard/tools/nfctool/sniffer.c b/neard/tools/nfctool/sniffer.c new file mode 100644 index 0000000..71ac612 --- /dev/null +++ b/neard/tools/nfctool/sniffer.c
@@ -0,0 +1,379 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <ctype.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <netdb.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <linux/tcp.h> +#include <linux/ip.h> +#include <errno.h> +#include <glib.h> + +#include <near/nfc_copy.h> + +#include "nfctool.h" +#include "llcp-decode.h" +#include "sniffer.h" + +#define PCAP_MAGIC_NUMBER 0xa1b2c3d4 +#define PCAP_MAJOR_VER 2 +#define PCAP_MINOR_VER 4 +#define PCAP_SNAP_LEN 0xFFFF +#define PCAP_NETWORK 0xF5 + +#define BUFFER_LEN 0x8FF + +static GIOChannel *gio_channel = NULL; +guint watch = 0; + +static FILE *pcap_file = NULL; +static guint8 *buffer; + +static int pcap_file_write_packet(guint8 *data, guint32 len, + struct timeval *timestamp) +{ + guint32 val32; + guint32 incl_len; + + if (!pcap_file || !data || len == 0) + return -EINVAL; + + val32 = timestamp->tv_sec; + if (fwrite(&val32, 4, 1, pcap_file) < 1) + goto exit_err; + + val32 = timestamp->tv_usec; + if (fwrite(&val32, 4, 1, pcap_file) < 1) + goto exit_err; + + if (len > PCAP_SNAP_LEN) + incl_len = PCAP_SNAP_LEN; + else + incl_len = len; + + if (fwrite(&incl_len, 4, 1, pcap_file) < 1) + goto exit_err; + + if (fwrite(&len, 4, 1, pcap_file) < 1) + goto exit_err; + + if (fwrite(data, 1, incl_len, pcap_file) < incl_len) + goto exit_err; + + return 0; + +exit_err: + return -errno; +} + +static int pcap_file_init(char *pcap_filename) +{ + int err = 0; + guint16 value16; + guint32 value32; + + pcap_file = fopen(pcap_filename, "w"); + + if (!pcap_file) { + err = errno; + print_error("Can't open file %s: %s", + pcap_filename, strerror(err)); + return -err; + } + + value32 = PCAP_MAGIC_NUMBER; + if (fwrite(&value32, 4, 1, pcap_file) < 1) + goto exit_err; + + value16 = PCAP_MAJOR_VER; + if (fwrite(&value16, 2, 1, pcap_file) < 1) + goto exit_err; + + value16 = PCAP_MINOR_VER; + if (fwrite(&value16, 2, 1, pcap_file) < 1) + goto exit_err; + + value32 = 0; + if (fwrite(&value32, 4, 1, pcap_file) < 1) + goto exit_err; + if (fwrite(&value32, 4, 1, pcap_file) < 1) + goto exit_err; + + value32 = PCAP_SNAP_LEN; + if (fwrite(&value32, 4, 1, pcap_file) < 1) + goto exit_err; + + value32 = PCAP_NETWORK; + if (fwrite(&value32, 4, 1, pcap_file) < 1) + goto exit_err; + + return 0; + +exit_err: + return -errno; +} + +static void pcap_file_cleanup(void) +{ + if (pcap_file) { + fclose(pcap_file); + pcap_file = NULL; + } +} + + +#define LINE_SIZE (10 + 3 * 16 + 2 + 18 + 1) +#define HUMAN_READABLE_OFFSET 55 + +/* + * Dumps data in Hex+ASCII format as: + * + * 00000000: 01 01 43 20 30 70 72 6F 70 65 72 74 69 65 73 20 |..C 0properties | + * + */ +void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, + guint8 indent, bool print_len) +{ + guint8 digits; + guint32 offset; + guint32 total; + guint32 output_len; + gchar line[LINE_SIZE]; + gchar *hexa = NULL, *human = NULL; + guint8 offset_len; + guint8 human_offset; + gchar *fmt; + + if (len == 0) + return; + + offset = 0; + digits = 0; + total = 0; + + if (opts.snap_len && len > opts.snap_len) + output_len = opts.snap_len; + else + output_len = len; + + if (output_len > 0xFFFF) { + offset_len = 8; + human_offset = HUMAN_READABLE_OFFSET + 4; + fmt = "%08X: "; + } else { + offset_len = 4; + human_offset = HUMAN_READABLE_OFFSET; + fmt = "%04X: "; + } + + if (print_len) { + if (indent) + fprintf(file, "%*c", indent, ' '); + + fprintf(file, "Total length: %u bytes\n", len); + } + + while (total < output_len) { + if (digits == 0) { + memset(line, ' ', human_offset); + + sprintf(line, fmt, offset); + + offset += 16; + + hexa = line + offset_len + 2; + + human = line + human_offset; + *human++ = '|'; + } + + sprintf(hexa, "%02hhX ", data[total]); + *human++ = isprint((int)data[total]) ? (char)data[total] : '.'; + hexa += 3; + + if (++digits >= 16) { + *hexa = ' '; + strcpy(human, "|"); + if (indent) + fprintf(file, "%*c", indent, ' '); + fprintf(file, "%s\n", line); + + digits = 0; + } + + total++; + } + + if ((output_len & 0xF) != 0) { + *hexa = ' '; + strcpy(human, "|"); + if (indent) + fprintf(file, "%*c", indent, ' '); + fprintf(file, "%s\n", line); + } + + if (output_len != len) { + if (indent) + fprintf(file, "%*c", indent, ' '); + fprintf(file, "--- truncated ---\n"); + } +} + +static gboolean gio_handler(GIOChannel *channel, + GIOCondition cond, gpointer data) +{ + struct msghdr msg; + struct iovec iov; + int sock; + int len; + guint8 ctrl[CMSG_SPACE(sizeof(struct timeval))]; + struct cmsghdr *cmsg; + struct timeval msg_timestamp; + + if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR)) { + print_error("Sniffer IO error 0x%x\n", cond); + + if (watch > 0) + g_source_remove(watch); + watch = 0; + gio_channel = NULL; + + return FALSE; + } + + sock = g_io_channel_unix_get_fd(channel); + + memset(&msg, 0, sizeof(struct msghdr)); + + msg.msg_control = &ctrl; + msg.msg_controllen = sizeof(ctrl); + + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + iov.iov_base = buffer; + iov.iov_len = BUFFER_LEN; + + len = recvmsg(sock, &msg, 0); + if (len < 0) { + print_error("recv: %s", strerror(errno)); + return FALSE; + } + + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg && cmsg->cmsg_type == SCM_TIMESTAMP) + memcpy(&msg_timestamp, CMSG_DATA(cmsg), sizeof(struct timeval)); + else + gettimeofday(&msg_timestamp, NULL); + + llcp_print_pdu(buffer, len, &msg_timestamp); + + pcap_file_write_packet(buffer, len, &msg_timestamp); + + return TRUE; +} + +void sniffer_cleanup(void) +{ + DBG("gio_channel: %p", gio_channel); + + if (gio_channel) { + g_io_channel_shutdown(gio_channel, TRUE, NULL); + g_io_channel_unref(gio_channel); + + gio_channel = NULL; + } + + pcap_file_cleanup(); + + llcp_decode_cleanup(); +} + +int sniffer_init(void) +{ + struct sockaddr_nfc_llcp sockaddr; + int sock = 0; + int err; + int one = 1; + + buffer = g_malloc(BUFFER_LEN); + + sock = socket(AF_NFC, SOCK_RAW, NFC_SOCKPROTO_LLCP); + + if (sock < 0) { + print_error("socket: %s", strerror(errno)); + return -1; + } + + err = setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one)); + if (err < 0) + print_error("setsockopt: %s", strerror(errno)); + + memset(&sockaddr, 0, sizeof(struct sockaddr_nfc_llcp)); + sockaddr.sa_family = AF_NFC; + sockaddr.dev_idx = opts.adapter_idx; + sockaddr.nfc_protocol = NFC_PROTO_NFC_DEP; + + err = bind(sock, (struct sockaddr *)&sockaddr, + sizeof(struct sockaddr_nfc_llcp)); + + if (err < 0) { + print_error("bind: %s", strerror(errno)); + goto exit; + } + + gio_channel = g_io_channel_unix_new(sock); + g_io_channel_set_close_on_unref(gio_channel, TRUE); + + g_io_channel_set_encoding(gio_channel, NULL, NULL); + g_io_channel_set_buffered(gio_channel, FALSE); + + watch = g_io_add_watch(gio_channel, + G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR, + gio_handler, NULL); + + g_io_channel_unref(gio_channel); + + if (opts.pcap_filename) { + err = pcap_file_init(opts.pcap_filename); + if (err) + goto exit; + } + + err = llcp_decode_init(); + if (err) + goto exit; + + printf("Start sniffer on nfc%d\n\n", opts.adapter_idx); + +exit: + if (err) + sniffer_cleanup(); + + return err; +}
diff --git a/neard/tools/nfctool/sniffer.h b/neard/tools/nfctool/sniffer.h new file mode 100644 index 0000000..887c305 --- /dev/null +++ b/neard/tools/nfctool/sniffer.h
@@ -0,0 +1,65 @@ +/* + * + * Near Field Communication nfctool + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __SNIFFER_H +#define __SNIFFER_H + +#ifndef AF_NFC +#define AF_NFC 39 +#endif + +struct sniffer_packet { + guint8 adapter_idx; + guint8 direction; + + struct { + guint8 ptype; + guint8 local_sap; + guint8 remote_sap; + + guint8 send_seq; + guint8 recv_seq; + + guint8 *data; + guint32 data_len; + } llcp; + + struct { + guint8 version; + + guint8 rcode; + + guint32 acceptable_len; + + guint8 *data; + guint32 data_len; + guint32 real_len; + } snep; +}; + +int sniffer_init(void); + +void sniffer_cleanup(void); + +void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, + guint8 indent, bool print_len); + +#endif /* __SNIFFER_H */
diff --git a/neard/tools/snep-send.c b/neard/tools/snep-send.c new file mode 100644 index 0000000..5bb1532 --- /dev/null +++ b/neard/tools/snep-send.c
@@ -0,0 +1,120 @@ +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <stdint.h> +#include <string.h> +#include <sys/time.h> +#include <sys/types.h> +#include <sys/socket.h> + +#include <linux/socket.h> + +#include <near/nfc_copy.h> +#include <near/types.h> +#include <near/ndef.h> + +#include "../src/near.h" + +/* HACK HACK */ +#ifndef AF_NFC +#define AF_NFC 39 +#endif + +#define SNEP_VERSION 0x10 + +/* Request codes */ +#define SNEP_REQ_CONTINUE 0x00 +#define SNEP_REQ_GET 0x01 +#define SNEP_REQ_PUT 0x02 +#define SNEP_REQ_REJECT 0x7f + +/* Response codes */ +#define SNEP_RESP_CONTINUE 0x80 +#define SNEP_RESP_SUCCESS 0x81 +#define SNEP_RESP_NOT_FOUND 0xc0 +#define SNEP_RESP_EXCESS 0xc1 +#define SNEP_RESP_BAD_REQ 0xc2 +#define SNEP_RESP_NOT_IMPL 0xe0 +#define SNEP_RESP_VERSION 0xe1 +#define SNEP_RESP_REJECT 0xff + +struct p2p_snep_req_frame { + uint8_t version; + uint8_t request; + uint32_t length; + uint8_t ndef[]; +} __attribute__((packed)); + +int main(int argc, char *argv[]) +{ + int fd, len; + struct near_ndef_message *ndef; + int adapter_idx, target_idx; + struct sockaddr_nfc_llcp addr; + struct p2p_snep_req_frame *frame; + size_t frame_length; + + if (argc < 3) { + printf("Usage: %s <adapter index> <target index>\n", argv[0]); + exit(0); + } + + adapter_idx = atoi(argv[1]); + target_idx = atoi(argv[2]); + + fd = socket(AF_NFC, SOCK_STREAM, NFC_SOCKPROTO_LLCP); + if (fd < 0) + return -1; + + memset(&addr, 0, sizeof(struct sockaddr_nfc_llcp)); + addr.sa_family = AF_NFC; + addr.dev_idx = adapter_idx; + addr.target_idx = target_idx; + addr.nfc_protocol = NFC_PROTO_NFC_DEP; + addr.service_name_len = strlen("urn:nfc:sn:snep"); + strcpy(addr.service_name, "urn:nfc:sn:snep"); + + if (connect(fd, (struct sockaddr *)&addr, + sizeof(struct sockaddr_nfc_llcp)) < 0) { + near_error("Connect error %s\n", strerror(errno)); + return -1; + } + + ndef = near_ndef_prepare_text_record("UTF-8", "en", "Hello world"); + if (!ndef) { + close(fd); + near_error("Could not build NDEF"); + return -1; + } + + frame_length = sizeof(struct p2p_snep_req_frame) + ndef->length; + frame = g_try_malloc0(frame_length); + if (!frame) { + close(fd); + near_error("Could not allocate SNEP frame"); + return -1; + } + + frame->version = SNEP_VERSION; + frame->request = SNEP_REQ_PUT; + frame->length = GUINT_TO_BE(ndef->length); + + memcpy(frame->ndef, ndef->data, ndef->length); + + len = send(fd, (uint8_t *)frame, frame_length, 0); + if (len < 0) { + near_error("Could not send text NDEF %s\n", strerror(errno)); + + g_free(frame); + close(fd); + + return -1; + } + + DBG("Sent %d bytes", len); + + g_free(frame); + close(fd); + + return 0; +}
diff --git a/neard/unit/test-ndef-build.c b/neard/unit/test-ndef-build.c new file mode 100644 index 0000000..7ff2222 --- /dev/null +++ b/neard/unit/test-ndef-build.c
@@ -0,0 +1,114 @@ +/* + * neard - Near Field Communication manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> + +#include <glib.h> +#include <glib/gprintf.h> + +#include "src/near.h" +#include "include/ndef.h" + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +/* 'hello' - UTF-8 - en-US Text NDEF */ +static uint8_t text[] = {0xd1, 0x1, 0xb, 0x54, 0x5, 0x65, 0x6e, 0x2d, + 0x55, 0x53, 0x68, 0x65, 0x6c, 0x6c, 0x6f}; + +/* SSID - 'TestSSID', Passphrase - 'Testpass' WSC MIME NDEF */ +static uint8_t wsc[] = {0xD2, 0x17, 0x1E, 0x61, 0x70, 0x70, 0x6C, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x76, + 0x6E, 0x64, 0x2E, 0x77, 0x66, 0x61, 0x2E, 0x77, + 0x73, 0x63, 0x10, 0x45, 0x00, 0x08, 0x54, 0x65, + 0x73, 0x74, 0x53, 0x53, 0x49, 0x44, 0x10, 0x03, + 0x00, 0x02, 0x00, 0x22, 0x10, 0x27, 0x00, 0x08, + 0x54, 0x65, 0x73, 0x74, 0x70, 0x61, 0x73, 0x73}; + +/* SSID - 'TestSSID' WSC MIME NDEF */ +static uint8_t wsc_wo[] = {0xD2, 0x17, 0x12, 0x61, 0x70, 0x70, 0x6C, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x76, + 0x6E, 0x64, 0x2E, 0x77, 0x66, 0x61, 0x2E, 0x77, + 0x73, 0x63, 0x10, 0x45, 0x00, 0x08, 0x54, 0x65, + 0x73, 0x74, 0x53, 0x53, 0x49, 0x44, 0x10, 0x03, + 0x00, 0x02, 0x00, 0x01}; + +static void test_ndef_text_build(void) +{ + struct near_ndef_message *ndef; + + ndef = near_ndef_prepare_text_record("UTF-8", "en-US", "hello"); + + g_assert(ndef); + g_assert(ndef->length == ARRAY_SIZE(text)); + g_assert(!memcmp(ndef->data, text, ARRAY_SIZE(text))); +} + +static void test_ndef_wsc_with_passphrase_build(void) +{ + struct near_ndef_message *ndef; + + ndef = near_ndef_prepare_wsc_record("TestSSID", "Testpass"); + + g_assert(ndef); + g_assert(ndef->length == ARRAY_SIZE(wsc)); + g_assert(!memcmp(ndef->data, wsc, ARRAY_SIZE(wsc))); +} + +static void test_ndef_wsc_with_out_passphrase_build(void) +{ + struct near_ndef_message *ndef; + + ndef = near_ndef_prepare_wsc_record("TestSSID", NULL); + + g_assert(ndef); + g_assert(ndef->length == ARRAY_SIZE(wsc_wo)); + g_assert(!memcmp(ndef->data, wsc_wo, ARRAY_SIZE(wsc_wo))); +} + +static void test_ndef_wsc_with_out_ssid_build(void) +{ + struct near_ndef_message *ndef; + + ndef = near_ndef_prepare_wsc_record(NULL, NULL); + + g_assert(!ndef); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + g_test_add_func("/testNDEF-build/Test Text NDEF", test_ndef_text_build); + g_test_add_func("/testNDEF-build/Test WSC with SSID and Passphrase NDEF" + , test_ndef_wsc_with_passphrase_build); + g_test_add_func("/testNDEF-build/Test WSC with only SSID NDEF", + test_ndef_wsc_with_out_passphrase_build); + g_test_add_func("/testNDEF-build/Test WSC with out SSID NDEF", + test_ndef_wsc_with_out_ssid_build); + + return g_test_run(); +}
diff --git a/neard/unit/test-ndef-parse.c b/neard/unit/test-ndef-parse.c new file mode 100644 index 0000000..8cfdc8f --- /dev/null +++ b/neard/unit/test-ndef-parse.c
@@ -0,0 +1,434 @@ +/* + * neard - Near Field Communication manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> + +#include <glib.h> +#include <glib/gprintf.h> + +#include "src/near.h" +#include "include/ndef.h" + +enum record_type { + RECORD_TYPE_WKT_SMART_POSTER = 0x01, + RECORD_TYPE_WKT_URI = 0x02, + RECORD_TYPE_WKT_TEXT = 0x03, + RECORD_TYPE_WKT_SIZE = 0x04, + RECORD_TYPE_WKT_TYPE = 0x05, + RECORD_TYPE_WKT_ACTION = 0x06, + RECORD_TYPE_WKT_HANDOVER_REQUEST = 0x07, + RECORD_TYPE_WKT_HANDOVER_SELECT = 0x08, + RECORD_TYPE_WKT_HANDOVER_CARRIER = 0x09, + RECORD_TYPE_WKT_ALTERNATIVE_CARRIER = 0x0a, + RECORD_TYPE_WKT_COLLISION_RESOLUTION = 0x0b, + RECORD_TYPE_WKT_ERROR = 0x0c, + RECORD_TYPE_MIME_TYPE = 0x0d, + RECORD_TYPE_EXT_AAR = 0x0e, + RECORD_TYPE_UNKNOWN = 0xfe, + RECORD_TYPE_ERROR = 0xff +}; + +struct near_ndef_record_header { + uint8_t mb; + uint8_t me; + uint8_t cf; + uint8_t sr; + uint8_t il; + uint8_t tnf; + uint8_t il_length; + uint8_t *il_field; + uint32_t payload_len; + uint32_t offset; + uint8_t type_len; + enum record_type rec_type; + char *type_name; + uint32_t header_len; +}; + +struct near_ndef_text_payload { + char *encoding; + char *language_code; + char *data; +}; + +struct near_ndef_uri_payload { + uint8_t identifier; + + uint32_t field_length; + uint8_t *field; +}; + +struct near_ndef_sp_payload { + struct near_ndef_uri_payload *uri; + + uint8_t number_of_title_records; + struct near_ndef_text_payload **title_records; + + uint32_t size; /* from Size record*/ + char *type; /* from Type record*/ + char *action; +}; + +struct near_ndef_aar_payload { + char *package; +}; + +struct near_ndef_record { + char *path; + + struct near_ndef_record_header *header; + + /* specific payloads */ + struct near_ndef_text_payload *text; + struct near_ndef_uri_payload *uri; + struct near_ndef_sp_payload *sp; + struct near_ndef_mime_payload *mime; + struct near_ndef_ho_payload *ho; /* handover payload */ + struct near_ndef_aar_payload *aar; + + char *type; + + uint8_t *data; + size_t data_len; +}; + +struct near_ndef_ho_payload { + uint8_t version; /* version id */ + uint16_t collision_record; /* collision record */ + + uint8_t number_of_ac_payloads; /* At least 1 ac is needed */ + struct near_ndef_ac_payload **ac_payloads; + + /* Optional records */ + uint16_t *err_record; /* not NULL if present */ + + uint8_t number_of_cfg_payloads; /* extra NDEF records */ + struct near_ndef_mime_payload **cfg_payloads; +}; + +struct near_ndef_ac_payload { + enum carrier_power_state cps; /* carrier power state */ + + uint8_t cdr_len; /* carrier data reference length: 0x01 */ + uint8_t *cdr; /* carrier data reference */ + uint8_t adata_refcount; /* auxiliary data reference count */ + + /* !: if adata_refcount == 0, then there's no data reference */ + uint16_t **adata; /* auxiliary data reference */ +}; + +/* http://www.intel.com URI NDEF */ +static uint8_t uri[] = {0xd1, 0x1, 0xa, 0x55, 0x1, 0x69, 0x6e, 0x74, + 0x65, 0x6c, 0x2e, 0x63, 0x6f, 0x6d}; + +/* 'hello' - UTF-8 - en-US Text NDEF */ +static uint8_t text[] = {0xd1, 0x1, 0xb, 0x54, 0x5, 0x65, 0x6e, 0x2d, + 0x55, 0x53, 0x68, 0x65, 0x6c, 0x6c, 0x6f}; + +/* Smart poster with a http://intel.com URI record */ +static uint8_t single_sp[] = {0xd1, 0x2, 0xe, 0x53, 0x70, 0xd1, 0x1, 0xa, + 0x55, 0x3, 0x69, 0x6e, 0x74, 0x65, 0x6c, 0x2e, + 0x63, 0x6f, 0x6d}; + +/* Smart poster with a http://intel.com URI record and a 'Intel' title */ +static uint8_t title_sp[] = {0xd1, 0x2, 0x1a, 0x53, 0x70, 0x91, 0x1, 0xa, + 0x55, 0x3, 0x69, 0x6e, 0x74, 0x65, 0x6c, 0x2e, + 0x63, 0x6f, 0x6d, 0x51, 0x1, 0x8, 0x54, 0x2, + 0x65, 0x6e, 0x49, 0x6e, 0x74, 0x65, 0x6c}; + +/* AAR record with a "com.example.aar" package name */ +static uint8_t aar[] = {0xd4, 0xf, 0xf, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, + 0x64, 0x2e, 0x63, 0x6f, 0x6d, 0x3a, 0x70, 0x6b, 0x67, + 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x2e, 0x61, 0x61, 0x72}; + +/* Sample Bluetooth Handover Select Message on an NFC Forum Tag */ +static uint8_t ho_hs_bt[] = {0x91, 0x02, 0x0A, 0x48, 0x73, 0x12, 0xD1, 0x02, + 0x04, 0x61, 0x63, 0x03, 0x01, 0x30, 0x00, 0x5A, + 0x20, 0x1F, 0x01, 0x61, 0x70, 0x70, 0x6C, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x76, + 0x6E, 0x64, 0x2E, 0x62, 0x6C, 0x75, 0x65, 0x74, + 0x6F, 0x6F, 0x74, 0x68, 0x2E, 0x65, 0x70, 0x2E, + 0x6F, 0x6F, 0x62, 0x30, 0x1F, 0x00, 0x03, 0x07, + 0x80, 0x88, 0xbf, 0x01, 0x04, 0x0D, 0x80, 0x06, + 0x04, 0x05, 0x03, 0x18, 0x11, 0x23, 0x11, 0x0B, + 0x09, 0x44, 0x65, 0x79, 0x69, 0x63, 0x65, 0x4e, + 0x61, 0x6d, 0x65}; + +static void test_ndef_free_record(struct near_ndef_record *record) +{ + g_free(record->header); + g_free(record->type); + g_free(record->data); + g_free(record); + +} + +static void test_ndef_uri(void) +{ + GList *records; + struct near_ndef_record *record; + + records = near_ndef_parse_msg(uri, sizeof(uri), NULL); + + g_assert(records); + g_assert(g_list_length(records) == 1); + + record = (struct near_ndef_record *)(records->data); + + g_assert(record->header->rec_type == RECORD_TYPE_WKT_URI); + g_assert(record->header->mb == 1); + g_assert(record->header->me == 1); + + g_assert(record->uri); + g_assert(record->uri->field_length == strlen("intel.com")); + g_assert(strncmp((char *) record->uri->field, "intel.com", + record->uri->field_length) == 0); + + if (g_test_verbose()) + g_print("NDEF URI field: %s\n", record->uri->field); + + g_free(record->uri->field); + g_free(record->uri); + test_ndef_free_record(record); +} + +static void test_ndef_text(void) +{ + GList *records; + struct near_ndef_record *record; + + records = near_ndef_parse_msg(text, sizeof(text), NULL); + + g_assert(records); + g_assert(g_list_length(records) == 1); + + record = (struct near_ndef_record *)(records->data); + + g_assert(record->header->rec_type == RECORD_TYPE_WKT_TEXT); + g_assert(record->header->mb == 1); + g_assert(record->header->me == 1); + + g_assert(record->text); + g_assert(strcmp(record->text->data, "hello") == 0); + g_assert(strcmp(record->text->encoding, "UTF-8") == 0); + g_assert(strcmp(record->text->language_code, "en-US") == 0); + + if (g_test_verbose()) { + g_print("NDEF Text data: %s\n", record->text->data); + g_print("NDEF Text Encoding: %s\n", record->text->encoding); + g_print("NDEF Text Language: %s\n", + record->text->language_code); + } + + g_free(record->text->data); + g_free(record->text->encoding); + g_free(record->text->language_code); + g_free(record->text); + test_ndef_free_record(record); +} + +static void test_ndef_single_sp(void) +{ + GList *records; + struct near_ndef_record *record; + struct near_ndef_uri_payload *uri; + + records = near_ndef_parse_msg(single_sp, sizeof(single_sp), NULL); + + g_assert(records); + g_assert(g_list_length(records) == 1); + + record = (struct near_ndef_record *) records->data; + + g_assert(record->header->rec_type == RECORD_TYPE_WKT_SMART_POSTER); + g_assert(record->header->mb == 1); + g_assert(record->header->me == 1); + + g_assert(record->sp); + g_assert(record->sp->number_of_title_records == 0); + g_assert(!record->sp->type); + g_assert(!record->sp->action); + g_assert(record->sp->size == 0); + g_assert(record->sp->uri); + + uri = (struct near_ndef_uri_payload *) record->sp->uri; + + g_assert(uri->field_length == strlen("intel.com")); + g_assert(strncmp((char *) uri->field, "intel.com", + uri->field_length) == 0); + + if (g_test_verbose()) + g_print("NDEF SP URI field: %.*s\n", uri->field_length, + (char *) uri->field); + + g_free(uri->field); + g_free(uri); + g_free(record->sp); + test_ndef_free_record(record); +} + +static void test_ndef_title_sp(void) +{ + GList *records; + struct near_ndef_record *record; + struct near_ndef_uri_payload *uri; + struct near_ndef_text_payload *text; + + + records = near_ndef_parse_msg(title_sp, sizeof(title_sp), NULL); + + g_assert(records); + g_assert(g_list_length(records) == 1); + + record = (struct near_ndef_record *) records->data; + + g_assert(record->header->rec_type == RECORD_TYPE_WKT_SMART_POSTER); + g_assert(record->header->mb == 1); + g_assert(record->header->me == 1); + + g_assert(record->sp); + g_assert(record->sp->number_of_title_records == 1); + g_assert(!record->sp->type); + g_assert(!record->sp->action); + g_assert(record->sp->size == 0); + g_assert(record->sp->uri); + g_assert(record->sp->title_records[0]); + + uri = (struct near_ndef_uri_payload *) record->sp->uri; + text = (struct near_ndef_text_payload *) record->sp->title_records[0]; + + g_assert(uri->field_length == strlen("intel.com")); + g_assert(strncmp((char *) uri->field, "intel.com", + uri->field_length) == 0); + + if (g_test_verbose()) + g_print("NDEF SP URI field: %.*s\n", uri->field_length, + (char *) uri->field); + + g_assert(strcmp(text->data, "Intel") == 0); + g_assert(strcmp(text->encoding, "UTF-8") == 0); + g_assert(strcmp(text->language_code, "en") == 0); + + if (g_test_verbose()) { + g_print("NDEF SP Title data: %s\n", text->data); + g_print("NDEF SP Title Encoding: %s\n", text->encoding); + g_print("NDEF SP Title Language: %s\n", text->language_code); + } + + g_free(uri->field); + g_free(uri); + + g_free(text->data); + g_free(text->encoding); + g_free(text->language_code); + g_free(text); + + g_free(record->sp); + test_ndef_free_record(record); +} + +static void test_ndef_aar(void) +{ + GList *records; + struct near_ndef_record *record; + + records = near_ndef_parse_msg(aar, sizeof(aar), NULL); + + g_assert(records); + g_assert(g_list_length(records) == 1); + + record = (struct near_ndef_record *)(records->data); + + g_assert(record->header->rec_type == RECORD_TYPE_EXT_AAR); + g_assert(record->header->mb == 1); + g_assert(record->header->me == 1); + + g_assert(record->aar); + g_assert(record->aar->package); + g_assert(strcmp((char *) record->aar->package, "com.example.aar") == 0); + + + if (g_test_verbose()) + g_print("NDEF AAR package: %s\n", record->aar->package); + + g_free(record->aar->package); + g_free(record->aar); + test_ndef_free_record(record); +} + +static void test_ndef_ho_hs_bt(void) +{ + GList *records; + struct near_ndef_record *record; + struct near_ndef_ho_payload *ho; + struct near_ndef_ac_payload *ac; + + /* TODO + * It is not possible to run HO code as unit test now as this code does + * both parsing and acting (eg. trying to access HO agent) in same run. + * Don't enable this test until it is fixed. + */ + return; + + records = near_ndef_parse_msg(ho_hs_bt, sizeof(ho_hs_bt), NULL); + + g_assert(records); + g_assert(g_list_length(records) == 2); + + record = records->data; + ho = record->ho; + + g_assert(ho->number_of_ac_payloads == 1); + + ac = ho->ac_payloads[0]; + + g_assert(ac->cdr_len == 1); + g_assert(memcmp(ac->cdr, "0", ac->cdr_len) == 0); + + records = g_list_next(records); + record = records->data; + g_assert(strcmp(record->type, BT_MIME_STRING_2_1) == 0); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + g_test_add_func("/testNDEF-parse/Test URI NDEF", test_ndef_uri); + g_test_add_func("/testNDEF-parse/Test Text NDEF", test_ndef_text); + g_test_add_func("/testNDEF-parse/Test Single record SmartPoster NDEF", + test_ndef_single_sp); + g_test_add_func("/testNDEF-parse/Test Title record SmartPoster NDEF", + test_ndef_title_sp); + g_test_add_func("/testNDEF-parse/Android Application Record NDEF", + test_ndef_aar); + g_test_add_func("/testNDEF-parse/Test Handover Select NDEF", + test_ndef_ho_hs_bt); + + return g_test_run(); +}
diff --git a/neard/unit/test-snep-read.c b/neard/unit/test-snep-read.c new file mode 100644 index 0000000..03c916a --- /dev/null +++ b/neard/unit/test-snep-read.c
@@ -0,0 +1,956 @@ +/* + * neard - Near Field Communication manager + * + * Copyright (C) 2013 Mobica Limited. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <stdint.h> +#include <string.h> +#include <unistd.h> +#include <sys/time.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <linux/socket.h> + +#include <near/types.h> + +#include "test-utils.h" + +#define TEST_SNEP_LOG(fmt, ...) do { \ + if (g_test_verbose()) {\ + g_printf("[SNEP unit] " fmt, ##__VA_ARGS__); \ + } \ + } while (0) + +#define TEST_SNEP_PTR_UNUSED(x) do { if ((void *)x) {} } while (0) + +static const char *short_text = "neard"; + +static const char *long_text = "The Linux NFC project aims to provide a " \ + "full NFC support for Linux. It is based on the neard NFC user space "\ + "stack running on top of the Linux kernel NFC subsystem. NFC stands " \ + "Near Field Communication. It is a short-range (a few centimeters)"\ + "radio technology that enables communication between devices that " \ + "either touch or are momentarily held close together. NFC is an open "\ + "technology standardized by the NFC Forum. It is based on RFID. "; + +/* 'neard' - UTF-8 - en-US Text NDEF */ +static uint8_t text[] = { 0xd1, 0x1, 0xb, 0x54, 0x5, 0x65, 0x6e, + 0x2d, 0x55, 0x53, 0x6e, 0x65, 0x61, 0x72, 0x64 }; + +/* sockets */ +static int sockfd[2]; +static int client; +static int server; + +struct test_snep_context { + uint8_t snep_version; + uint32_t req_info_len; + uint32_t payload_len; + uint8_t *req_info; + + uint32_t acc_len; /* req GET specific */ + + struct near_ndef_message *test_recd_msg; +}; + +/* variables used in dummy_req_{get|put} */ +static struct test_snep_context *gcontext; +static struct near_ndef_record *stored_recd; +static GSList *test_fragments; + +/* GET/PUT server functions */ + +/* + * @brief Utility: Dummy PUT request handler + */ +static bool test_snep_dummy_req_put(int fd, void *data) +{ + struct p2p_snep_data *snep_data = data; + GList *records; + uint8_t *nfc_data; + uint32_t nfc_data_length; + uint32_t offset = 0; + + TEST_SNEP_LOG(">> dummy_req_put entry %p\n", data); + + if (!snep_data) + goto error; + + if (stored_recd) + TEST_SNEP_LOG("\tdummy_req_put already stored record\n"); + + if (snep_data->nfc_data_length > snep_data->nfc_data_current_length) + return true; + + test_fragments = g_slist_append(test_fragments, snep_data); + + nfc_data_length = 0; + nfc_data = g_try_malloc0(snep_data->nfc_data_length); + g_assert(nfc_data); + + while (g_slist_length(test_fragments) > 0) { + static int frag_cnt; + struct p2p_snep_data *fragment = test_fragments->data; + + TEST_SNEP_LOG("\tdummy_req_put frag=%d, len=%d, current=%d\n", + frag_cnt, fragment->nfc_data_length, + fragment->nfc_data_current_length); + test_fragments = g_slist_remove(test_fragments, fragment); + + memcpy(nfc_data + offset, fragment->nfc_data, + fragment->nfc_data_current_length - nfc_data_length); + + offset += fragment->nfc_data_current_length - nfc_data_length; + nfc_data_length = offset; + + frag_cnt++; + } + + records = near_ndef_parse_msg(nfc_data, nfc_data_length, NULL); + if (!records) { + TEST_SNEP_LOG("\tdummy_req_put parsing ndef failed\n"); + goto error; + } + + if (g_list_length(records) != 1) { + TEST_SNEP_LOG("\tdummy_req_put records number mismatch"); + goto error; + } + + g_free(nfc_data); + + stored_recd = records->data; + + TEST_SNEP_LOG("\t\tdummy_req_put STORED REC data=%p length=%zu\n", + stored_recd->data, stored_recd->data_len); + + near_snep_core_response_noinfo(fd, NEAR_SNEP_RESP_SUCCESS); + return true; + +error: + TEST_SNEP_LOG("\tdummy_req_put error!!!\n"); + return false; +} + +/* + * @brief Utility: Dummy GET request handler + */ +static bool test_snep_dummy_req_get(int fd, void *data) +{ + struct p2p_snep_data *snep_data = data; + + TEST_SNEP_LOG(">> dummy_req_get entry %p\n", data); + + if (!snep_data) + goto error; + + TEST_SNEP_LOG("\t\tdummy_req_get STORED REC data=%p length=%zu\n", + stored_recd->data, stored_recd->data_len); + + near_snep_core_response_with_info(fd, NEAR_SNEP_RESP_SUCCESS, + near_ndef_data_ptr(stored_recd), + near_ndef_data_length(stored_recd)); + return true; + +error: + TEST_SNEP_LOG("\tdummy_req_get error!!!\n"); + return false; +} + +static void test_snep_init(gpointer context, gconstpointer data) +{ + struct test_snep_context *ctx = context; + struct timeval tv; + int ret; + const char *test_data = data; + + g_assert(socketpair(PF_LOCAL, SOCK_STREAM, 0, sockfd) == 0); + + client = 0; + server = 1; + + tv.tv_sec = 1; + tv.tv_usec = 0; + ret = setsockopt(sockfd[client], SOL_SOCKET, SO_RCVTIMEO, + (const void *) &tv, sizeof(tv)); + if (ret != 0) + TEST_SNEP_LOG("set sock SO_RCVTIMEO failed"); + + __near_snep_core_init(); + + stored_recd = NULL; + + ctx->test_recd_msg = test_ndef_create_test_record(test_data); + + ctx->snep_version = NEAR_SNEP_VERSION; + ctx->req_info = ctx->test_recd_msg->data; + ctx->req_info_len = ctx->test_recd_msg->length; + ctx->payload_len = ctx->test_recd_msg->length; + ctx->acc_len = 64; + + gcontext = ctx; +} + +static void test_snep_cleanup(gpointer context, gconstpointer data) +{ + struct test_snep_context *ctx = context; + + __near_snep_core_cleanup(); + + if (stored_recd) + test_ndef_free_record(stored_recd); + + if (ctx->test_recd_msg) { + g_free(ctx->test_recd_msg->data); + g_free(ctx->test_recd_msg); + } + + g_slist_free(test_fragments); + + close(sockfd[client]); + close(sockfd[server]); + + gcontext = NULL; +} + +/* + * @brief Utility: Allocate and build SNEP request frame. + * + * @param[in] frame_len Size of the entire frame + * @param[in] ver SNEP protocol version field + * @param[in] resp_type SNEP response code field + * @param[in] info_len SNEP info length field + * @param[in] data SNEP info field + * @param[in] payload_len Size of the payload to be inserted + * @return p2p_snep_resp_frame + */ +static struct p2p_snep_req_frame *test_snep_build_req_frame( + size_t frame_len, uint8_t ver, uint8_t req_type, + uint32_t info_len, uint8_t *data, uint32_t payload_len) +{ + struct p2p_snep_req_frame *req; + + req = g_try_malloc0(frame_len); + g_assert(req); + + req->version = ver; + req->request = req_type; + req->length = GUINT_TO_BE(info_len); + memcpy(req->ndef, data, payload_len); + + return req; +} + +/* + * @brief Utility: Allocate and build SNEP GET request frame. + * + * @param[in] frame_len Size of the entire frame + * @param[in] ver SNEP protocol version field + * @param[in] resp_type SNEP response code field + * @param[in] info_len SNEP info length field + * @param[in] data SNEP info field + * @param[in] acc_len SNEP acceptable length field + * @param[in] payload_len Size of the payload to be inserted + * @return p2p_snep_resp_frame + */ +static struct p2p_snep_req_frame *test_snep_build_req_get_frame( + size_t frame_len, uint8_t ver, uint8_t req_type, + uint32_t info_len, uint32_t acc_len, uint8_t *data, + uint32_t payload_len) +{ + struct p2p_snep_req_frame *req; + uint32_t acc_len_be = GUINT_TO_BE(acc_len); + + req = g_try_malloc0(frame_len); + g_assert(req); + + req->version = ver; + req->request = req_type; + req->length = GUINT_TO_BE(info_len); + memcpy(req->ndef, &acc_len_be, sizeof(acc_len_be)); + memcpy(req->ndef + sizeof(acc_len_be), data, payload_len); + + return req; +} + +/* + * @brief Utility: Allocate and build SNEP response frame. + * + * @param[in] frame_len Size of the entire frame + * @param[in] ver SNEP protocol version field + * @param[in] resp_type SNEP response code field + * @param[in] info_len SNEP info length field + * @param[in] data SNEP info field + * @return p2p_snep_resp_frame + */ +static struct p2p_snep_resp_frame *test_snep_build_resp_frame( + size_t frame_len, uint8_t ver, uint8_t resp_type, + uint32_t info_len, uint8_t *data) +{ + struct p2p_snep_resp_frame *resp; + + resp = g_try_malloc0(frame_len); + g_assert(resp); + + resp->version = ver; + resp->response = resp_type; + resp->length = GUINT_TO_BE(info_len); + memcpy(resp->info, data, info_len); + + return resp; +} + +/* + * @brief Utility: Send the \p req frame to the socket and call + * near_snep_core_read + * + * @param[in] req Request frame to send + * @param[in] frame_len Size of the frame + * @param[in] req_get GET server function + * @param[in] req_put PUT server function + * @return near_bool_t returned by near_snep_core_read + */ +static bool test_snep_read_req_common( + struct p2p_snep_req_frame *req, size_t frame_len, + near_server_io req_get, near_server_io req_put) +{ + bool ret; + size_t nbytes; + + nbytes = send(sockfd[client], req, frame_len, 0); + g_assert(nbytes == frame_len); + + TEST_SNEP_LOG("sent 0x%02X request\n", req->request); + + ret = near_snep_core_read(sockfd[server], 0, 0, NULL, req_get, req_put, + NULL); + + return ret; +} + +/* + * @brief Utility: Send \p frame_len bytes of the fragment \p data + * to the socket and call near_snep_core_read + * + * @param[in] frag_len + * @param[in] data + * @return near_bool_t returned by near_snep_core_read + * + * @note does not call near_snep_core_read for now, since it can't handle + * frame without SNEP header + */ +static bool test_snep_read_send_fragment(size_t frag_len, + uint8_t *data) +{ + size_t nbytes; + + nbytes = send(sockfd[client], data, frag_len, 0); + g_assert(nbytes == frag_len); + + near_snep_core_read(sockfd[server], 0, 0, NULL, + test_snep_dummy_req_get, test_snep_dummy_req_put, + NULL); + + return true; +} + +/* + * @brief Utility: Receive remaining fragments and store in \p data_recvd + * + * @param[in] frag_len + * @param[in] remaining_bytes + * @param[out] data Must be preallocated + */ +static void test_snep_read_recv_fragments(uint32_t frag_len, + uint32_t remaining_bytes, void *data_recvd) +{ + struct p2p_snep_resp_frame *resp; + uint32_t offset = 0; + int nbytes; + + g_assert(data_recvd); + + resp = g_try_malloc0(frag_len); + g_assert(resp); + + do { + memset(resp, 0, frag_len); + + /* receive remaining fragments */ + nbytes = recv(sockfd[client], resp, frag_len, 0); + g_assert(nbytes > 0); /* TODO use explicit value? */ + + /* store received data (no header this time) */ + memcpy(data_recvd + offset, resp, nbytes); + offset += nbytes; + } while (offset < remaining_bytes); + + g_free(resp); +} + +/* + * @brief Utility: Confirm that server didn't send any response + */ +static void test_snep_read_no_response(void) +{ + struct p2p_snep_resp_frame *resp; + int nbytes; + + resp = g_try_malloc0(sizeof(*resp)); + g_assert(resp); + + nbytes = recv(sockfd[client], resp, sizeof(*resp), MSG_DONTWAIT); + g_assert(nbytes < 0); + g_assert(errno == EAGAIN); + + g_free(resp); +} + +/* + * @brief Utility: Verify response sent by the server + * + * @param[in] exp_resp_code Expected response code + * @param[in] exp_resp_info_len Expected response info length + * @param[in] exp_resp_info Expected response info + */ +static void test_snep_read_verify_resp(int exp_resp_code, + uint32_t exp_resp_info_len, uint8_t *exp_resp_info) +{ + struct p2p_snep_resp_frame *resp; + size_t nbytes, frame_len; + + frame_len = NEAR_SNEP_RESP_HEADER_LENGTH + exp_resp_info_len; + resp = test_snep_build_resp_frame(frame_len, 0, 0, 0, NULL); + g_assert(resp); + + nbytes = recv(sockfd[client], resp, frame_len, 0); + g_assert(nbytes == frame_len); + + TEST_SNEP_LOG("received response = 0x%02X, exp = 0x%02X\n", + resp->response, exp_resp_code); + + g_assert(resp->version == NEAR_SNEP_VERSION); + g_assert(resp->response == exp_resp_code); + g_assert(resp->length == GUINT_TO_BE(exp_resp_info_len)); + g_assert(!memcmp(resp->info, exp_resp_info, exp_resp_info_len)); + + g_free(resp); +} + +/* + * @brief Utility: Verify code of the response sent by the server + * + * @param[in] exp_resp_code Expected response code + */ +static void test_snep_read_verify_resp_code(int exp_resp_code) +{ + test_snep_read_verify_resp(exp_resp_code, 0, NULL); +} + +/* + * @brief Test: Confirm that server is able to handle PUT request + * + * Steps: + * - Send well-formed PUT request + * - Verify server responded with SUCCESS + */ +static void test_snep_read_put_req_ok(gpointer context, gconstpointer gp) +{ + struct test_snep_context *ctx = context; + struct p2p_snep_req_frame *req; + uint32_t frame_len, payload_len; + bool ret; + + payload_len = ctx->req_info_len; + frame_len = NEAR_SNEP_REQ_PUT_HEADER_LENGTH + payload_len; + + req = test_snep_build_req_frame(frame_len, NEAR_SNEP_VERSION, + NEAR_SNEP_REQ_PUT, ctx->req_info_len, + ctx->req_info, payload_len); + + ret = test_snep_read_req_common(req, frame_len, test_snep_dummy_req_get, + test_snep_dummy_req_put); + g_assert(ret); + + test_snep_read_verify_resp_code(NEAR_SNEP_RESP_SUCCESS); + + g_free(req); +} + +/* + * @brief Test: Confirm that server checks the version field of the request. + * + * Steps: + * - Send PUT request with incorrect version field + * - Verify server responded with UNSUPPORTED VERSION + */ +static void test_snep_read_put_req_unsupp_ver(gpointer context, + gconstpointer gp) +{ + struct test_snep_context *ctx = context; + struct p2p_snep_req_frame *req; + uint32_t frame_len, payload_len; + bool ret; + + payload_len = ctx->req_info_len; + frame_len = NEAR_SNEP_REQ_PUT_HEADER_LENGTH + payload_len; + + req = test_snep_build_req_frame(frame_len, 0xF8, NEAR_SNEP_REQ_PUT, + ctx->req_info_len, ctx->req_info, payload_len); + + ret = test_snep_read_req_common(req, frame_len, test_snep_dummy_req_get, + test_snep_dummy_req_put); + g_assert(ret); + + test_snep_read_verify_resp_code(NEAR_SNEP_RESP_VERSION); + + g_free(req); +} + +/* + * @brief Test: Confirm that server responds about no support for the + * functionality in request message + * + * Steps: + * - Send PUT request + * - Pass NULL PUT request handler to the near_snep_core_read + * - Verify server responded with NOT IMPLEMENTED + */ +static void test_snep_read_put_req_not_impl(gpointer context, + gconstpointer gp) +{ + struct test_snep_context *ctx = context; + struct p2p_snep_req_frame *req; + uint32_t frame_len, payload_len; + bool ret; + + payload_len = ctx->req_info_len; + frame_len = NEAR_SNEP_REQ_PUT_HEADER_LENGTH + payload_len; + + req = test_snep_build_req_frame(frame_len, NEAR_SNEP_VERSION, + NEAR_SNEP_REQ_PUT, ctx->req_info_len, + ctx->req_info, payload_len); + + ret = test_snep_read_req_common(req, frame_len, test_snep_dummy_req_get, + NULL); + g_assert(ret); + + test_snep_read_verify_resp_code(NEAR_SNEP_RESP_NOT_IMPL); + + g_free(req); +} + +/* + * @brief Test: Confirm that server is able to receive fragmented request msg + * + * Steps: + * - Send PUT request with incomplete data + * - Verify server responded with CONTINUE + * - Send second fragment of the message + * - Verify server didn't respond + * - Send last fragment of the message + * - Verify server responded with SUCCESS + */ +static void test_snep_read_put_req_fragmented(gpointer context, + gconstpointer gp) +{ + struct test_snep_context *ctx = context; + struct p2p_snep_req_frame *req; + uint32_t frame_len, payload_len; + bool ret; + + payload_len = ctx->req_info_len / 3; + frame_len = NEAR_SNEP_REQ_PUT_HEADER_LENGTH + payload_len; + + req = test_snep_build_req_frame(frame_len, NEAR_SNEP_VERSION, + NEAR_SNEP_REQ_PUT, ctx->req_info_len, + ctx->req_info, payload_len); + + /* send 1st fragment within PUT request */ + ret = test_snep_read_req_common(req, frame_len, test_snep_dummy_req_get, + test_snep_dummy_req_put); + g_assert(ret); + + test_snep_read_verify_resp_code(NEAR_SNEP_RESP_CONTINUE); + + /* send 2nd fragment */ + ret = test_snep_read_send_fragment(payload_len, + ctx->req_info + payload_len); + g_assert(ret); + + /* do not expect a response */ + test_snep_read_no_response(); + + /* send last fragment */ + ret = test_snep_read_send_fragment(ctx->req_info_len - 2 * payload_len, + ctx->req_info + 2 * payload_len); + g_assert(ret); + + /* + * TODO expected SUCCESS response: + * test_snep_read_verify_resp_code(NEAR_SNEP_RESP_SUCCESS); + */ + + TEST_SNEP_LOG("EXPECTED FAIL: fragments are not received by SNEP\n"); + + g_free(req); +} + +/* + * @brief Test: Confirm that server is able to handle GET request + * + * Steps: + * - Send PUT request with some data + * - Send GET request + * - Verify server responded with SUCCESS and correct data + */ +static void test_snep_read_get_req_ok(gpointer context, gconstpointer gp) +{ + struct test_snep_context *ctx = context; + struct p2p_snep_req_frame *req; + uint32_t frame_len, payload_len, info_len; + bool ret; + + /* send some data to the server */ + test_snep_read_put_req_ok(context, gp); + + info_len = ctx->req_info_len + NEAR_SNEP_ACC_LENGTH_SIZE; + payload_len = ctx->req_info_len; + + frame_len = NEAR_SNEP_REQ_GET_HEADER_LENGTH + payload_len; + + req = test_snep_build_req_get_frame(frame_len, NEAR_SNEP_VERSION, + NEAR_SNEP_REQ_GET, info_len, + ctx->acc_len, ctx->req_info, payload_len); + + ret = test_snep_read_req_common(req, frame_len, test_snep_dummy_req_get, + test_snep_dummy_req_put); + g_assert(ret); + + test_snep_read_verify_resp(NEAR_SNEP_RESP_SUCCESS, ctx->req_info_len, + ctx->req_info); + + g_free(req); +} + +/* + * @brief Test: Confirm that server responds about no support for the + * functionality in request message + * + * Steps: + * - Send PUT request with some data + * - Send GET request + * - Pass NULL GET request handler to the near_snep_core_read + * - Verify server responded with NOT IMPLEMENTED + */ +static void test_snep_read_get_req_not_impl(gpointer context, + gconstpointer gp) +{ + struct test_snep_context *ctx = context; + struct p2p_snep_req_frame *req; + uint32_t frame_len, payload_len; + bool ret; + + /* send some data to the server */ + test_snep_read_put_req_ok(context, gp); + + payload_len = ctx->req_info_len; + frame_len = NEAR_SNEP_REQ_GET_HEADER_LENGTH + payload_len; + + /* build REQ GET frame */ + req = test_snep_build_req_get_frame(frame_len, NEAR_SNEP_VERSION, + NEAR_SNEP_REQ_GET, ctx->req_info_len, ctx->acc_len, + ctx->req_info, payload_len); + + /* call snep_core_read with NULL req_get handler */ + ret = test_snep_read_req_common(req, frame_len, NULL, + test_snep_dummy_req_put); + g_assert(ret); + + test_snep_read_verify_resp_code(NEAR_SNEP_RESP_NOT_IMPL); + + g_free(req); +} + +/* + * @brief Test: Confirm that server is able to respond with fragmented message + * + * Steps: + * - Send PUT request with some data + * - Send GET request with Acceptable Length less than actual data length + * - Verify that server returned with incomplete data + * - Send CONTINUE or REJECT request (depending on \p client_resp param) + * - If REJECT requested, verify that server didn't respond + * - If CONTINUE requested, receive remaining fragments and verify data + */ +static void test_snep_read_get_req_frags_client_resp(gpointer context, + gconstpointer gp, uint8_t client_resp) +{ + struct test_snep_context *ctx = context; + struct p2p_snep_req_frame *req; + struct p2p_snep_resp_frame *resp; + uint32_t frame_len, payload_len; + bool ret; + size_t nbytes; + uint8_t *data_recvd; + uint32_t offset; + uint32_t frag_len, info_len; + + /* send some data to the server */ + test_snep_read_put_req_ok(context, gp); + + payload_len = ctx->req_info_len; + frame_len = NEAR_SNEP_REQ_GET_HEADER_LENGTH + payload_len; + + /* force fragmentation */ + ctx->acc_len = 60; + g_assert(ctx->acc_len < ctx->req_info_len); + g_assert(NEAR_SNEP_REQ_MAX_FRAGMENT_LENGTH < ctx->req_info_len); + + /* TODO frag_len should be calculated based on SNEP acc_len */ + TEST_SNEP_LOG("WORKAROUND: SNEP core ignores the acceptable length\n"); + frag_len = NEAR_SNEP_REQ_MAX_FRAGMENT_LENGTH; + + info_len = ctx->req_info_len + NEAR_SNEP_ACC_LENGTH_SIZE; + + req = test_snep_build_req_get_frame(frame_len, NEAR_SNEP_VERSION, + NEAR_SNEP_REQ_GET, info_len, + ctx->acc_len, ctx->req_info, payload_len); + + /* send GET request */ + ret = test_snep_read_req_common(req, frame_len, test_snep_dummy_req_get, + test_snep_dummy_req_put); + g_assert(ret); + g_free(req); + + frame_len = NEAR_SNEP_RESP_HEADER_LENGTH + payload_len; + resp = test_snep_build_resp_frame(frame_len, 0, 0, 0, NULL); + + /* start receiving fragments */ + nbytes = recv(sockfd[client], resp, frame_len, 0); + g_assert(nbytes == frag_len); + g_assert(resp->length == GUINT_TO_BE(ctx->req_info_len)); + g_assert(resp->info); + + data_recvd = g_try_malloc0(ctx->req_info_len); + g_assert(data_recvd); + + /* store received info field */ + memcpy(data_recvd, resp->info, nbytes - NEAR_SNEP_RESP_HEADER_LENGTH); + g_free(resp); + + offset = nbytes - NEAR_SNEP_RESP_HEADER_LENGTH; + + /* 1st fragment has been received, so request resp=CONTINUE/REJECT */ + frame_len = NEAR_SNEP_REQ_PUT_HEADER_LENGTH; + req = test_snep_build_req_frame(frame_len, NEAR_SNEP_VERSION, + client_resp, 0, NULL, 0); + + ret = test_snep_read_req_common(req, frame_len, NULL, NULL); + g_free(req); + + if (client_resp == NEAR_SNEP_REQ_REJECT) { + g_assert(ret); + test_snep_read_no_response(); + } else if (client_resp == NEAR_SNEP_REQ_CONTINUE) { + g_assert(ret); + + /* receive remaining fragments */ + test_snep_read_recv_fragments(frag_len, + ctx->req_info_len - offset, + data_recvd + offset); + + /* verify data */ + g_assert(!memcmp(data_recvd, ctx->req_info, + ctx->req_info_len)); + } + + g_free(data_recvd); +} + +/* Refer to the test_snep_read_get_req_frags_client_resp for description */ +static void test_snep_read_get_frags_continue(gpointer context, + gconstpointer gp) +{ + test_snep_read_get_req_frags_client_resp(context, gp, + NEAR_SNEP_REQ_CONTINUE); +} + +/* Refer to the test_snep_read_get_req_frags_client_resp for description */ +static void test_snep_read_get_frags_reject(gpointer context, + gconstpointer gp) +{ + test_snep_read_get_req_frags_client_resp(context, gp, + NEAR_SNEP_REQ_REJECT); +} + +/* + * @brief Test: Confirm that server is able to send simple response + */ +static void test_snep_response_noinfo(gpointer context, gconstpointer gp) +{ + int bytes_recv; + struct p2p_snep_resp_frame resp; + + near_snep_core_response_noinfo(sockfd[client], NEAR_SNEP_RESP_SUCCESS); + + bytes_recv = recv(sockfd[server], &resp, sizeof(resp), 0); + g_assert(bytes_recv == NEAR_SNEP_RESP_HEADER_LENGTH); + g_assert(resp.version == NEAR_SNEP_VERSION); + g_assert(resp.response == NEAR_SNEP_RESP_SUCCESS); + g_assert(resp.length == 0); +} + +/* + * @brief Test: Confirm that server is able to communicate with the client + */ +static void test_snep_response_put_get_ndef(gpointer context, + gconstpointer gp) +{ + size_t nbytes; + + struct p2p_snep_req_frame *req; + struct p2p_snep_resp_frame *resp; + struct near_ndef_message *ndef; + + bool ret; + uint frame_len; + + ndef = near_ndef_prepare_text_record("UTF-8", "en-US", "neard"); + g_assert(ndef); + g_assert(ndef->data); + g_assert(ndef->length > 0); + + frame_len = NEAR_SNEP_RESP_HEADER_LENGTH + ndef->length; + + req = g_try_malloc0(frame_len); + g_assert(req); + + req->version = 0x10; + req->request = NEAR_SNEP_REQ_PUT; + req->length = GUINT_TO_BE(ndef->length); + memcpy(req->ndef, ndef->data, ndef->length); + + /* Send PUT request with text record */ + nbytes = send(sockfd[server], req, frame_len, 0); + g_assert(nbytes == frame_len); + + /* UUT */ + ret = near_snep_core_read(sockfd[client], 0, 0, NULL, + test_snep_dummy_req_get, test_snep_dummy_req_put, NULL); + g_assert(ret); + + resp = g_try_malloc0(frame_len); + g_assert(resp); + + /* Get response from server */ + nbytes = recv(sockfd[server], resp, frame_len, 0); + g_assert(nbytes > 0); + g_assert(resp->response == NEAR_SNEP_RESP_SUCCESS); + + /* Send GET request to retrieve a record */ + req->request = NEAR_SNEP_REQ_GET; + req->length = 0; + nbytes = send(sockfd[server], req, NEAR_SNEP_RESP_HEADER_LENGTH, 0); + g_assert(nbytes > 0); + + /* UUT */ + ret = near_snep_core_read(sockfd[client], 0, 0, NULL, + test_snep_dummy_req_get, test_snep_dummy_req_put, NULL); + g_assert(ret); + + /* Get response and verify */ + nbytes = recv(sockfd[server], resp, frame_len, 0); + g_assert(nbytes > 0); + g_assert(resp->response == NEAR_SNEP_RESP_SUCCESS); + g_assert(resp->length == GUINT_TO_BE(ndef->length)); + g_assert(!memcmp(resp->info, text, ndef->length)); + + g_free(req); + g_free(resp); + g_free(ndef->data); + g_free(ndef); +} + +int main(int argc, char **argv) +{ + GTestSuite *ts; + GTestFixtureFunc init = test_snep_init; + GTestFixtureFunc exit = test_snep_cleanup; + size_t fs = sizeof(struct test_snep_context); + + g_test_init(&argc, &argv, NULL); + + ts = g_test_create_suite("testSNEP-response"); + g_test_suite_add(ts, + g_test_create_case("noinfo", fs, short_text, + init, test_snep_response_noinfo, exit)); + + g_test_suite_add_suite(g_test_get_root(), ts); + + ts = g_test_create_suite("testSNEP-readGET"); + g_test_suite_add(ts, + g_test_create_case("Request ok", fs, short_text, + init, test_snep_read_get_req_ok, exit)); + g_test_suite_add(ts, + g_test_create_case("Request not implemented", fs, short_text, + init, test_snep_read_get_req_not_impl, exit)); + g_test_suite_add(ts, + g_test_create_case("Request fragmented CONTINUE", + fs, long_text, init, + test_snep_read_get_frags_continue, exit)); + g_test_suite_add(ts, + g_test_create_case("Request fragmented REJECT", + fs, long_text, init, + test_snep_read_get_frags_reject, exit)); + + g_test_suite_add_suite(g_test_get_root(), ts); + + ts = g_test_create_suite("testSNEP-readPUT"); + g_test_suite_add(ts, + g_test_create_case("Request ok", fs, short_text, + init, test_snep_read_put_req_ok, exit)); + g_test_suite_add(ts, + g_test_create_case("Request unsupported ver", fs, short_text, + init, test_snep_read_put_req_unsupp_ver, exit)); + g_test_suite_add(ts, + g_test_create_case("Request not implemented", fs, short_text, + init, test_snep_read_put_req_not_impl, exit)); + g_test_suite_add(ts, + g_test_create_case("Request fragmented", fs, long_text, + init, test_snep_read_put_req_fragmented, exit)); + + g_test_suite_add_suite(g_test_get_root(), ts); + + ts = g_test_create_suite("testSNEP-misc"); + g_test_suite_add(ts, + g_test_create_case("PUT and GET request NDEF", + fs, short_text, init, + test_snep_response_put_get_ndef, exit)); + + g_test_suite_add_suite(g_test_get_root(), ts); + + return g_test_run(); +}
diff --git a/neard/unit/test-utils.c b/neard/unit/test-utils.c new file mode 100644 index 0000000..fe25656 --- /dev/null +++ b/neard/unit/test-utils.c
@@ -0,0 +1,40 @@ +/* + * neard - Near Field Communication manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "test-utils.h" + +void test_ndef_free_record(struct near_ndef_record *record) +{ + g_free(record->header); + g_free(record->type); + g_free(record->data); + g_free(record); +} + +struct near_ndef_message *test_ndef_create_test_record(const char *str) +{ + struct near_ndef_message *ndef; + + ndef = near_ndef_prepare_text_record("UTF-8", "en-US", (char *) str); + g_assert(ndef); + g_assert(ndef->data); + + return ndef; +}
diff --git a/neard/unit/test-utils.h b/neard/unit/test-utils.h new file mode 100644 index 0000000..c371d56 --- /dev/null +++ b/neard/unit/test-utils.h
@@ -0,0 +1,150 @@ +/* + * neard - Near Field Communication manager + * + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef UNIT_TEST_UTILS_H +#define UNIT_TEST_UTILS_H + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <stdint.h> +#include <string.h> +#include <unistd.h> + +#include <src/near.h> +#include <near/nfc_copy.h> +#include <near/types.h> +#include <near/ndef.h> +#include <glib.h> +#include <glib/gprintf.h> + +/* SNEP specific types */ +struct snep_fragment { + uint32_t len; + uint8_t *data; +}; + +struct p2p_snep_put_req_data { + uint8_t fd; + uint32_t adapter_idx; + uint32_t target_idx; + near_device_io_cb cb; + guint watch; + + GSList *fragments; +}; + +struct p2p_snep_req_frame { + uint8_t version; + uint8_t request; + uint32_t length; + uint8_t ndef[]; +} __attribute__((packed)); + +struct p2p_snep_resp_frame { + uint8_t version; + uint8_t response; + uint32_t length; + uint8_t info[]; +} __attribute__((packed)); + +/* NDEF specific types */ +enum record_type { + RECORD_TYPE_WKT_SMART_POSTER = 0x01, + RECORD_TYPE_WKT_URI = 0x02, + RECORD_TYPE_WKT_TEXT = 0x03, + RECORD_TYPE_WKT_SIZE = 0x04, + RECORD_TYPE_WKT_TYPE = 0x05, + RECORD_TYPE_WKT_ACTION = 0x06, + RECORD_TYPE_WKT_HANDOVER_REQUEST = 0x07, + RECORD_TYPE_WKT_HANDOVER_SELECT = 0x08, + RECORD_TYPE_WKT_HANDOVER_CARRIER = 0x09, + RECORD_TYPE_WKT_ALTERNATIVE_CARRIER = 0x0a, + RECORD_TYPE_WKT_COLLISION_RESOLUTION = 0x0b, + RECORD_TYPE_WKT_ERROR = 0x0c, + RECORD_TYPE_MIME_TYPE = 0x0d, + RECORD_TYPE_UNKNOWN = 0xfe, + RECORD_TYPE_ERROR = 0xff +}; + +struct near_ndef_record_header { + uint8_t mb; + uint8_t me; + uint8_t cf; + uint8_t sr; + uint8_t il; + uint8_t tnf; + uint8_t il_length; + uint8_t *il_field; + uint32_t payload_len; + uint32_t offset; + uint8_t type_len; + enum record_type rec_type; + char *type_name; + uint32_t header_len; +}; + +struct near_ndef_text_payload { + char *encoding; + char *language_code; + char *data; +}; + +struct near_ndef_uri_payload { + uint8_t identifier; + + uint32_t field_length; + uint8_t *field; +}; + +struct near_ndef_sp_payload { + struct near_ndef_uri_payload *uri; + + uint8_t number_of_title_records; + struct near_ndef_text_payload **title_records; + + uint32_t size; /* from Size record*/ + char *type; /* from Type record*/ + char *action; +}; + +struct near_ndef_record { + char *path; + + struct near_ndef_record_header *header; + + /* specific payloads */ + struct near_ndef_text_payload *text; + struct near_ndef_uri_payload *uri; + struct near_ndef_sp_payload *sp; + struct near_ndef_mime_payload *mime; + struct near_ndef_ho_payload *ho; /* handover payload */ + + char *type; + + uint8_t *data; + size_t data_len; +}; + +void test_ndef_free_record(struct near_ndef_record *record); + +struct near_ndef_message *test_ndef_create_test_record(const char *str); + +#endif