Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:16.0:FactoryCandidates
biosdevname
biosdevname-0.7.3.7.g495ab76.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File biosdevname-0.7.3.7.g495ab76.obscpio of Package biosdevname
07070100000000000081A40000000000000000000000015F52709200000112000000000000000000000000000000000000002800000000biosdevname-0.7.3.7.g495ab76/.gitignore*.o *.in *~ Makefile Makefile.in aclocal.m4 autom4te.cache/ biosdevname.spec.fedora biosdevname.spec.suse config.h config.log config.status configure src/.deps/ src/.dirstamp src/biosdevname src/biosdevnameS src/dmidecode/.deps/ src/dmidecode/.dirstamp stamp-h1 version .pc 07070100000001000081A40000000000000000000000015F52709200000134000000000000000000000000000000000000002500000000biosdevname-0.7.3.7.g495ab76/AUTHORSMatt Domsch <Matt_Domsch@dell.com> All files not otherwise noted list.h: Cribbed from the Linux kernel 2.6.18. read_proc.c: Cribbed from net-tools-1.60 ethtool-copy.h: Cribbed from ethtool dmidecode/* Cribbed from dmidecode 2.9 Michael Brown <Michael_E_Brown@dell.com> autoconf/automake cleanups 07070100000002000081A40000000000000000000000015F52709200004648000000000000000000000000000000000000002500000000biosdevname-0.7.3.7.g495ab76/COPYING GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <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. 07070100000003000081A40000000000000000000000015F52709200000000000000000000000000000000000000000000002700000000biosdevname-0.7.3.7.g495ab76/ChangeLog07070100000004000081A40000000000000000000000015F52709200000442000000000000000000000000000000000000002900000000biosdevname-0.7.3.7.g495ab76/Makefile.amAUTOMAKE_OPTIONS = subdir-objects SUBDIRS = EXTRA_DIST = dist_noinst_DATA = biosdevname.rules.in biosdevname.spec.fedora biosdevname.spec.suse biosdevname.1 CLEANFILES = version src/bios_dev_name.h install-data-local: mkdir -p $(DESTDIR)@RULEDIR@ $(INSTALL_DATA) $(top_srcdir)/biosdevname.rules.in $(DESTDIR)@RULEDEST@ uninstall-local: rm -f $(DESTDIR)@RULEDEST@ include src/Makefile.am # extra space at beginning to work around automake... :( ifndef SPEC_FILE SPEC_FILE=biosdevname.spec.fedora endif rpm: dist mkdir -p dist/{SOURCES,BUILD,RPMS,SRPMS,SPECS} cp $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz dist/SOURCES cp $(SPEC_FILE) dist/SPECS/@PACKAGE_NAME@.spec rpmbuild --define "_topdir $$PWD/dist" -ba --nodeps dist/SPECS/@PACKAGE_NAME@.spec ; rm -rf dist/{SOURCES,BUILD,SPECS} srpm: dist mkdir -p dist/{SOURCES,BUILD,RPMS,SRPMS,SPECS} cp $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz dist/SOURCES cp $(SPEC_FILE) dist/SPECS/@PACKAGE_NAME@.spec rpmbuild --define "_topdir $$PWD/dist" -bs --nodeps dist/SPECS/@PACKAGE_NAME@.spec ; rm -rf dist/{SOURCES,BUILD,SPECS} 07070100000005000081A40000000000000000000000015F52709200000000000000000000000000000000000000000000002200000000biosdevname-0.7.3.7.g495ab76/NEWS07070100000006000081A40000000000000000000000015F527092000003F7000000000000000000000000000000000000002400000000biosdevname-0.7.3.7.g495ab76/READMEbiosdevname Copyright (c) 2006, 2007 Dell, Inc. <Matt_Domsch@dell.com> Licensed under the GNU General Public License, Version 2. biosdevname in its simplest form takes a kernel device name as an argument, and returns the BIOS-given name it "should" be. This is necessary on systems where the BIOS name for a given device (e.g. the label on the chassis is "Gb1") doesn't map directly and obviously to the kernel name (e.g. eth0). The distro-patches/sles10/ directory contains a patch needed to integrate biosdevname into the SLES10 udev ethernet naming rules. This also works as a straight udev rule. On RHEL4, that looks like: KERNEL=="eth*", ACTION=="add", PROGRAM="/sbin/biosdevname -i %k", NAME="%c" This makes use of various BIOS-provided tables: PCI Confuration Space PCI IRQ Routing Table ($PIR) PCMCIA Card Information Structure SMBIOS 2.6 Type 9, Type 41, and HP OEM-specific types therefore it's likely that this will only work well on architectures that provide such information in their BIOS. 07070100000007000081A40000000000000000000000015F5270920000003A000000000000000000000000000000000000002200000000biosdevname-0.7.3.7.g495ab76/TODO* fix Ubuntu builds to not require -lz, when Fedora does. 07070100000008000081ED0000000000000000000000015F527092000001DD000000000000000000000000000000000000002800000000biosdevname-0.7.3.7.g495ab76/autogen.sh#!/bin/bash # run this script to create all the autotools fluff. It will also run configure # unless told not to set -e CURDIR=$(pwd) SCRIPT_DIR=$(cd $(dirname $0); pwd) cd $SCRIPT_DIR autoreconf -i -f -Wno-portability run_configure=true for arg in $*; do case $arg in --no-configure) run_configure=false ;; *) ;; esac done if test $run_configure = true; then cd $CURDIR $SCRIPT_DIR/configure "$@" fi 07070100000009000081A40000000000000000000000015F52709200000DCF000000000000000000000000000000000000002B00000000biosdevname-0.7.3.7.g495ab76/biosdevname.1.\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH BIOSDEVNAME 1 "Nov 28, 2010" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp <n> insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME biosdevname \- give BIOS-given name of a device .SH SYNOPSIS .B biosdevname .RI [options]\ [args]... .SH DESCRIPTION biosdevname takes a kernel device name as an argument, and returns the BIOS-given name it "should" be. .SH OPTIONS .TP .B \-i, \-\-interface Treat [args] as ethernet devs .TP .B \-d, \-\-debug Enable debugging .TP .B \-p, \-\-policy \fI[physical|all_ethN] .TP .B \-P, \-\-prefix \fI[string] string use for embedded NICs in the physical policy (default=em) .TP .B \-x, \-\-nopirq Do not use $PIR table for mapping PCI device to slot. Some BIOS have incorrect values. .TP .B \-s, \-\-smbios \fI[x.y] Require minimum SMBIOS version x.y .SH POLICIES .br The .B physical policy is the current default. However, when invoking biosdevname in udev rules, one should always specify the policy you want, as the default has changed over time. .br The .B physical policy uses the following scheme: .TP em<port>[_<virtual instance>] for embedded NICs .TP p<slot>p<port>[_<virtual instance>] for cards in PCI slots .br .PP The .B all_ethN policy makes a best guess at what the device order should be, with embedded devices first, PCI cards in ascending slot order, and ports in ascending PCI bus/device/function order breadth-first. However, this policy .I does not work if your PCI devices are hot-plugged or hot-pluggable, including the virtual functions on an SR-IOV device. In a hot-plug scenario, each separate udev instance will be invoked in parallel, while the device tree is still being populated with new devices. Each udev instance will see a different PCI tree, and thus cannot provide consistent enumeration. Use of this policy should be limited to only scenarios where all PCI devices are present at boot (cold-plug). .SH EXIT CODES Returns 0 on success, with BIOS-suggested name printed to stdout. .br Returns 1 on provided device name lookup failure. .br Returns 2 if system BIOS does not provide naming information. biosdevname requires system BIOS to provide naming information, either via SMBIOS or sysfs files. .br Returns 3 if not run as root but requires root privileges. .br Returns 4 if running in a virtual machine. .SH SEE ALSO .br http://linux.dell.com/wiki/index.php/Oss/libnetdevname .br http://linux.dell.com/files/biosdevname/ .br git://linux.dell.com/biosdevname.git .SH RELATED PROGRAMS .br The .B dmidecode package contains two tools useful for debugging BIOS features that biosdevname uses, specifically .B dmidecode to read the SMBIOS Type 9 and Type 41 tables, and .B biosdecode to read the PCI IRQ Routing Table. Please include the output of each of these programs in any bug reports. .SH AUTHOR biosdevname was written by Matt Domsch <Matt_Domsch@dell.com> .PP This manual page was written by Rudy Gevaert <Rudy.Gevaert@UGent.be>, for the Debian project (but may be used by others). 0707010000000A000081A40000000000000000000000015F527092000003FE000000000000000000000000000000000000003200000000biosdevname-0.7.3.7.g495ab76/biosdevname.rules.inSUBSYSTEM!="net", GOTO="netdevicename_end" ACTION!="add", GOTO="netdevicename_end" NAME=="?*", GOTO="netdevicename_end" ATTR{type}!="1", GOTO="netdevicename_end" ENV{DEVTYPE}=="?*", GOTO="netdevicename_end" # kernel command line "biosdevname={0|1}" can turn off/on biosdevname IMPORT{cmdline}="biosdevname" ENV{biosdevname}=="?*", ENV{UDEV_BIOSDEVNAME}="$env{biosdevname}" # ENV{UDEV_BIOSDEVNAME} can be used for blacklist/whitelist # but will be overwritten by the kernel command line argument ENV{UDEV_BIOSDEVNAME}=="0", GOTO="netdevicename_end" ENV{UDEV_BIOSDEVNAME}=="1", GOTO="netdevicename_start" # uncomment the next line for biosdevname to be off by default # GOTO="netdevicename_end" LABEL="netdevicename_start" # using NAME= instead of setting INTERFACE_NAME, so that persistent # names aren't generated for these devices, they are "named" on each boot. SUBSYSTEMS=="pci", PROGRAM="/sbin/biosdevname --policy physical -i %k", NAME="%c", OPTIONS+="string_escape=replace" LABEL="netdevicename_end" 0707010000000B000081A40000000000000000000000015F527092000015E5000000000000000000000000000000000000003800000000biosdevname-0.7.3.7.g495ab76/biosdevname.spec.fedora.inName: biosdevname Version: @PACKAGE_VERSION@ Release: 1%{?dist} Summary: Udev helper for naming devices per BIOS names Group: System Environment/Base License: GPLv2 URL: http://linux.dell.com/files/%{name} # SMBIOS only exists on these arches. It's also likely that other # arches don't expect the PCI bus to be sorted breadth-first, or of # so, there haven't been any comments about that on LKML. ExclusiveArch: %{ix86} x86_64 Source0: http://linux.dell.com/files/%{name}/permalink/%{name}-%{version}.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: pciutils-devel, zlib-devel # to figure out how to name the rules file BuildRequires: udev #To generate the configure script BuildRequires: autoconf BuildRequires: automake # for ownership of /etc/udev/rules.d Requires: udev %description biosdevname in its simplest form takes a kernel device name as an argument, and returns the BIOS-given name it "should" be. This is necessary on systems where the BIOS name for a given device (e.g. the label on the chassis is "Gb1") doesn't map directly and obviously to the kernel name (e.g. eth0). %prep %setup -q %build #If configure script doesn't exist generate it with autogen script [ -e ./configure ] || ./autogen.sh --no-configure # this is a udev rule, so it needs to live in / rather than /usr %configure --disable-rpath --prefix=/ --sbindir=/sbin make %{?_smp_mflags} %install rm -rf %{buildroot} make install install-data DESTDIR=%{buildroot} %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) %doc COPYING README /sbin/%{name} # hack for either /etc or /lib rules location /*/udev/rules.d/*.rules %{_mandir}/man1/%{name}.1* %changelog * Tue Oct 4 2011 Praveen K Paladugu <praveen_paladugu@dell.com> - 0.3.11-1 - Fix man page for PCI slot naming - Fix clearing of buffer for NPAR/SRIOV naming - Add --nopirq and --smbios options to manpage. - Verify length of VPD on network device - Close file handle on sysfs read - Fix naming policy for NPAR devices. Match each PCI device to its VPD 'physical' device to get correct index - Exclude building on ia64 arch - Add support functions for determining PCIE slot - Scan full path to parent when getting PCIE slot - Fix NPAR naming for add-in cards - Don't display _vf suffix on NPAR devices with single function - Fix PCIe/PIRQ slot mapping * Thu Feb 17 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.7-1 - drop dump_pirq, suggest use biosdecode instead - don't use '#' in names, use 'p' instead, by popular demand - properly look for SMBIOS, then $PIR, then recurse - Add kernel command line parameter "biosdevname={0|1}" to turn off/on biosdevname - Fix segfault when BIOS advertises zero sized PIRQ Routing Table - Add 'bonding' and 'openvswitch' to the virtual devices list - fail PIRQ lookups if device domain is not 0 - Don't suggest names if running in a virtual machine (Xen, KVM, VMware tested, but should work on others) - Typo fixes * Tue Jan 25 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.6-1 - drop biosdevnameS, it's unused and fails to build on F15 * Tue Jan 25 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.5-1 - install dump_pirq into /usr/sbin - fix udev rule, skip running if NAME is already set - move udev rule to /lib/udev/rules.d by default * Thu Dec 16 2010 Matt Domsch <mdomsch@fedoraproject.org> - 0.3.4-1 - drop unnecessary explicit version requirement on udev - bugfix: start indices at 1 not 0, to match Dell and HP server port designations - bugfix: don't assign names to unknown devices - bugfix: don't assign duplicate names * Thu Dec 9 2010 Matt Domsch <Matt_Domsch@dell.com> - 0.3.3-1 - add back in use of PCI IRQ Routing Table, if info is not provided by sysfs or SMBIOS * Thu Dec 2 2010 Matt Domsch <Matt_Domsch@dell.com> - 0.3.2-1 - fix for multi-port cards with bridges - removal of code for seriously obsolete systems * Mon Nov 28 2010 Matt Domsch <Matt_Domsch@dell.com> 0.3.1-1 - remove all policies except 'physical' and 'all_ethN' - handle SR-IOV devices properly * Wed Nov 10 2010 Matt Domsch <Matt_Domsch@dell.com> 0.3.0-1 - add --policy=loms, make it default - read index and labels from sysfs if available * Mon Jul 27 2009 Jordan Hargrave <Jordan_Hargrave@dell.com> 0.2.5-1 - fix mmap error checking * Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2.4-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild * Mon Feb 23 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2.4-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild * Tue May 06 2008 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-5 - use policy=all_names to find breakage * Sun Feb 10 2008 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-4 - rebuild for gcc43 * Fri Sep 21 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-3 - fix manpage entry in files * Fri Sep 21 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-2 - rebuild with Requires: udev > 115-3.20070920git * Fri Sep 21 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-1 - coordinate udev rules usage with udev maintainer - fix crashes in pcmcia search, in_ethernet(), and incorrect command line parsing. * Mon Aug 27 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.3-1 - eliminate libbiosdevname.*, pre and post scripts * Fri Aug 24 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.2-1 - ExclusiveArch those arches with SMBIOS and PCI IRQ Routing tables - eliminate libsysfs dependency, move app to / for use before /usr is mounted. - build static * Mon Aug 20 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.1-1 - initial release 0707010000000C000081A40000000000000000000000015F52709200000FBF000000000000000000000000000000000000003600000000biosdevname-0.7.3.7.g495ab76/biosdevname.spec.suse.inName: biosdevname Version: @PACKAGE_VERSION@ Release: 1%{?dist} Summary: Udev helper for naming devices per BIOS names Group: System Environment/Base License: GPLv2 URL: http://linux.dell.com/files/%{name} # SMBIOS only exists on these arches. It's also likely that other # arches don't expect the PCI bus to be sorted breadth-first, or of # so, there haven't been any comments about that on LKML. ExclusiveArch: %{ix86} x86_64 Source0: http://linux.dell.com/files/%{name}/permalink/%{name}-%{version}.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: pciutils-devel, zlib-devel # to figure out how to name the rules file BuildRequires: udev # for ownership of /etc/udev/rules.d Requires: udev %description biosdevname in its simplest form takes a kernel device name as an argument, and returns the BIOS-given name it "should" be. This is necessary on systems where the BIOS name for a given device (e.g. the label on the chassis is "Gb1") doesn't map directly and obviously to the kernel name (e.g. eth0). %prep %setup -q %build # this is a udev rule, so it needs to live in / rather than /usr %configure --disable-rpath --prefix=/ --sbindir=/sbin make %{?_smp_mflags} %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) %doc COPYING README /sbin/%{name} # hack for either /etc or /lib rules location /*/udev/rules.d/*.rules %{_mandir}/man1/%{name}.1* %changelog * Thu Feb 17 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.7-1 - drop dump_pirq, suggest use biosdecode instead - don't use '#' in names, use 'p' instead, by popular demand - properly look for SMBIOS, then $PIR, then recurse - Add kernel command line parameter "biosdevname={0|1}" to turn off/on biosdevname - Fix segfault when BIOS advertises zero sized PIRQ Routing Table - Add 'bonding' and 'openvswitch' to the virtual devices list - fail PIRQ lookups if device domain is not 0 - Don't suggest names if running in a virtual machine (Xen, KVM, VMware tested, but should work on others) - Typo fixes * Tue Jan 25 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.6-1 - drop biosdevnameS, it's unused and fails to build on F15 * Tue Jan 25 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.5-1 - install dump_pirq into /usr/sbin - fix udev rule, skip running if NAME is already set - move udev rule to /lib/udev/rules.d by default * Thu Dec 16 2010 Matt Domsch <mdomsch@fedoraproject.org> - 0.3.4-1 - drop unnecessary explicit version requirement on udev - bugfix: start indices at 1 not 0, to match Dell and HP server port designations - bugfix: don't assign names to unknown devices - bugfix: don't assign duplicate names * Thu Dec 9 2010 Matt Domsch <Matt_Domsch@dell.com> - 0.3.3-1 - add back in use of PCI IRQ Routing Table, if info is not provided by sysfs or SMBIOS * Thu Dec 2 2010 Matt Domsch <Matt_Domsch@dell.com> - 0.3.2-1 - fix for multi-port cards with bridges - removal of code for seriously obsolete systems * Mon Nov 28 2010 Matt Domsch <Matt_Domsch@dell.com> 0.3.1-1 - remove all policies except 'physical' and 'all_ethN' - handle SR-IOV devices properly * Wed Nov 10 2010 Matt Domsch <Matt_Domsch@dell.com> 0.3.0-1 - add --policy=loms, make it default - read index and labels from sysfs if available * Mon Jul 27 2009 Jordan Hargrave <Jordan_Hargrave@dell.com> 0.2.5-1 - fix mmap error checking * Fri Sep 21 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-1 - coordinate udev rules usage with udev maintainer - fix crashes in pcmcia search, in_ethernet(), and incorrect command line parsing. * Mon Aug 27 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.3-1 - eliminate libbiosdevname.*, pre and post scripts * Fri Aug 24 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.2-1 - ExclusiveArch those arches with SMBIOS and PCI IRQ Routing tables - eliminate libsysfs dependency, move app to / for use before /usr is mounted. - build static * Mon Aug 20 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.1-1 - initial release 0707010000000D000081A40000000000000000000000015F52709200000B61000000000000000000000000000000000000002A00000000biosdevname-0.7.3.7.g495ab76/configure.ac# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. # vim:tw=0:ts=8:sw=8:et AC_PREREQ(2.59) AC_INIT([biosdevname],[0.7.3],[Jordan_Hargrave@dell.com]) AC_LANG([C]) AC_USE_SYSTEM_EXTENSIONS AC_CONFIG_SRCDIR([src/read_proc.c]) AC_CONFIG_HEADER([config.h]) AC_PREFIX_DEFAULT() AM_INIT_AUTOMAKE AM_MAINTAINER_MODE # Checks for programs. AC_PROG_AWK AC_PROG_CC AM_PROG_CC_C_O AC_PROG_LN_S AC_PROG_CXX AC_PROG_RANLIB AC_CHECK_PROGS([READELF], [readelf]) AC_CHECK_FUNCS([realpath]) # Checks for libraries. AC_CHECK_LIB([c], [snprintf]) # libz has to come before libpci because libpci needs it now. AC_CHECK_LIB([z], [gzopen], [true], [AC_MSG_ERROR([You must install zlib-devel (Fedora/Red Hat/SuSE), libzip-dev (Debian/Ubuntu), or equivalent])]) AC_CHECK_LIB([pci], [pci_alloc], [true], [AC_MSG_ERROR([You must install pciutils-devel (Fedora/Red Hat/SuSE), pciutils-dev (Debian/Ubuntu), or equivalent])], -lz) # Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([fcntl.h limits.h locale.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/time.h syslog.h unistd.h]) AC_CHECK_HEADER([pci/pci.h], , [AC_MSG_ERROR([You must install pciutils-devel or equivalent])]) AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([You must install zlib-devel or equivalent])]) # Check for pci_dev.domain AC_CHECK_MEMBERS([struct pci_dev.domain], , , [#include<pci/pci.h>]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_TYPE_OFF_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_TYPE_UINT8_T AC_TYPE_UINT16_T AC_HEADER_TIME AC_STRUCT_TM # Checks for library functions. AC_FUNC_ALLOCA AC_FUNC_FORK AC_PROG_GCC_TRADITIONAL AC_FUNC_MALLOC AC_FUNC_MEMCMP AC_FUNC_MMAP AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES AC_FUNC_STAT AC_FUNC_VPRINTF AC_CHECK_FUNCS([dup2 gettimeofday memset munmap select socket strcasecmp strchr strdup strerror strncasecmp strpbrk strrchr strstr strtol strtoul]) # this is ugly, but accounts for SLES 10, Red Hat/Fedora, and Ubuntu # handles default udev rules as of udev 114 or thereabouts RULEDEST=/lib/udev/rules.d/71-biosdevname.rules if [[ -e /etc/udev/rules.d/60-net.rules ]]; then # RHEL 5 / Fedora RULEDEST=/etc/udev/rules.d/60-biosdevname.rules elif [[ -e /etc/udev/rules.d/31-network.rules ]]; then # SLES 10 RULEDEST=/etc/udev/rules.d/31-biosdevname.rules elif [[ -e /etc/udev/rules.d/25-iftab.rules ]]; then # older Ubuntu RULEDEST=/etc/udev/rules.d/25-biosdevname.rules fi RULEDIR=$(dirname $RULEDEST) AC_SUBST(RULEDEST, $RULEDEST) AC_SUBST(RULEDIR, $RULEDIR) echo "PACKAGE_NAME='$PACKAGE_NAME'" > version echo "PACKAGE_VERSION='$PACKAGE_VERSION'" >> version echo "PACKAGE_STRING='$PACKAGE_STRING'" >> version AC_CONFIG_FILES([Makefile biosdevname.spec.fedora biosdevname.spec.suse src/bios_dev_name.h]) AC_OUTPUT 0707010000000E000041ED0000000000000000000000025F52709200000000000000000000000000000000000000000000002C00000000biosdevname-0.7.3.7.g495ab76/distro-patches0707010000000F000041ED0000000000000000000000025F52709200000000000000000000000000000000000000000000003300000000biosdevname-0.7.3.7.g495ab76/distro-patches/sles1007070100000010000081A40000000000000000000000015F527092000004CF000000000000000000000000000000000000004900000000biosdevname-0.7.3.7.g495ab76/distro-patches/sles10/rename_netiface.patch--- /etc/sysconfig/network/config.orig 2006-09-20 15:02:06.000000000 -0500 +++ /etc/sysconfig/network/config 2006-09-29 10:05:36.000000000 -0500 @@ -197,7 +197,16 @@ # FORCE_PERSISTENT_NAMES=yes +## Type: string +## Default: "" +# +# Force all interfaces eth* to use the given naming policy by +# querying the hardware for topology information. +# See biosdevname --help for the list of supported policies. +# +BIOSDEVNAME_POLICY="" + ## Type: yesno ## Default: no # --- /lib/udev/rename_netiface.orig 2006-09-20 16:10:51.000000000 -0500 +++ /lib/udev/rename_netiface 2006-09-29 10:14:15.000000000 -0500 @@ -139,7 +139,15 @@ # The latter serves as temporary registration file to avoid race # conditions. It will be removed when the script exits. - NEWNAME=$OLDNAME + # Try using the BIOS name + if [ -x /sbin/biosdevname ] ; then + unset POLICY + [ -n "$BIOSDEVNAME_POLICY" ] && + POLICY="--policy=$BIOSDEVNAME_POLICY" + NEWNAME="$(/sbin/biosdevname $POLICY -i $OLDNAME)" + fi + + [ -z "$NEWNAME" ] && NEWNAME=$OLDNAME get_device_id "$OLDNAME" "$2" if [ -z "$DEV_ID" ] ; then error_exit 4 "no device id for $OLDNAME" 07070100000011000081A40000000000000000000000015F5270920002FF58000000000000000000000000000000000000002700000000biosdevname-0.7.3.7.g495ab76/ltmain.sh# ltmain.sh - Provide generalized library-building support services. # NOTE: Changing this file will not affect anything until you rerun configure. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 # Free Software Foundation, Inc. # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. basename="s,^.*/,,g" # 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" # The name of this program: progname=`echo "$progpath" | $SED $basename` modename="$progname" # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 PROGRAM=ltmain.sh PACKAGE=libtool VERSION=1.5.22 TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)" # 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 # Check that we have a working $echo. if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then # Yippee, $echo works! : else # Restart under the correct shell, and then maybe $echo will work. exec $SHELL "$progpath" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat <<EOF $* EOF exit $EXIT_SUCCESS fi default_mode= help="Try \`$progname --help' for more information." magic="%%%MAGIC variable%%%" mkdir="mkdir" mv="mv -f" rm="rm -f" # 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' # 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 SP2NL='tr \040 \012' NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system SP2NL='tr \100 \n' NL2SP='tr \r\n \100\100' ;; esac # NLS nuisances. # Only set LANG and LC_ALL to C if already set. # These must not be set unconditionally because not all systems understand # e.g. LANG=C (notably SCO). # We save the old values to restore during execute mode. if test "${LC_ALL+set}" = set; then save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL fi if test "${LANG+set}" = set; then save_LANG="$LANG"; LANG=C; export LANG fi # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then $echo "$modename: not configured to build any kind of library" 1>&2 $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit $EXIT_FAILURE fi # Global variables. mode=$default_mode nonopt= prev= prevopt= run= show="$echo" show_help= execute_dlfiles= duplicate_deps=no preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" ##################################### # Shell function definitions: # This seems to be the best place for them # 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 "$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" || { $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2 exit $EXIT_FAILURE } fi $echo "X$my_tmpdir" | $Xsed } # 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. func_win32_libid () { 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 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then win32_nmres=`eval $NM -f posix -A $1 | \ $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_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 () { if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac CC_quoted="$CC_quoted $arg" done 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 "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; # 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. case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac CC_quoted="$CC_quoted $arg" done case "$@ " in " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) # 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 $echo "$modename: unable to infer tagged configuration" $echo "$modename: specify a tag with \`--tag'" 1>&2 exit $EXIT_FAILURE # else # $echo "$modename: using $tagname tagged configuration" fi ;; esac fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2 exit $EXIT_FAILURE fi } # func_extract_archives gentop oldlib ... func_extract_archives () { my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" my_status="" $show "${rm}r $my_gentop" $run ${rm}r "$my_gentop" $show "$mkdir $my_gentop" $run $mkdir "$my_gentop" my_status=$? if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then exit $my_status fi 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 my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` my_xdir="$my_gentop/$my_xlib" $show "${rm}r $my_xdir" $run ${rm}r "$my_xdir" $show "$mkdir $my_xdir" $run $mkdir "$my_xdir" exit_status=$? if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then exit $exit_status fi case $host in *-darwin*) $show "Extracting $my_xabs" # Do not bother doing anything if just a dry run if test -z "$run"; then darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` if test -n "$darwin_arches"; then darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= $show "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do 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 have a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` lipo -create -output "$darwin_file" $darwin_files done # $darwin_filelist ${rm}r unfat-$$ cd "$darwin_orig_dir" else cd "$darwin_orig_dir" func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches fi # $run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # End of Shell function definitions ##################################### # Darwin sucks eval std_shrext=\"$shrext_cmds\" disable_libs=no # Parse our command line options once, thoroughly. while test "$#" -gt 0 do arg="$1" shift case $arg in -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in execute_dlfiles) execute_dlfiles="$execute_dlfiles $arg" ;; tag) tagname="$arg" preserve_args="${preserve_args}=$arg" # Check whether tagname contains only valid characters case $tagname in *[!-_A-Za-z0-9,/]*) $echo "$progname: invalid tag name: $tagname" 1>&2 exit $EXIT_FAILURE ;; esac case $tagname in CC) # Don't test for the "default" C tag, as we know, it's there, but # not specially marked. ;; *) if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then taglist="$taglist $tagname" # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" else $echo "$progname: ignoring unknown tag $tagname" 1>&2 fi ;; esac ;; *) eval "$prev=\$arg" ;; esac prev= prevopt= continue fi # Have we seen a non-optional argument yet? case $arg in --help) show_help=yes ;; --version) $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" $echo $echo "Copyright (C) 2005 Free Software Foundation, Inc." $echo "This is free software; see the source for copying conditions. There is NO" $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." exit $? ;; --config) ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath # Now print the configurations for the tags. for tagname in $taglist; do ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" done exit $? ;; --debug) $echo "$progname: enabling shell trace mode" set -x preserve_args="$preserve_args $arg" ;; --dry-run | -n) run=: ;; --features) $echo "host: $host" if test "$build_libtool_libs" = yes; then $echo "enable shared libraries" else $echo "disable shared libraries" fi if test "$build_old_libs" = yes; then $echo "enable static libraries" else $echo "disable static libraries" fi exit $? ;; --finish) mode="finish" ;; --mode) prevopt="--mode" prev=mode ;; --mode=*) mode="$optarg" ;; --preserve-dup-deps) duplicate_deps="yes" ;; --quiet | --silent) show=: preserve_args="$preserve_args $arg" ;; --tag) prevopt="--tag" prev=tag preserve_args="$preserve_args --tag" ;; --tag=*) set tag "$optarg" ${1+"$@"} shift prev=tag preserve_args="$preserve_args --tag" ;; -dlopen) prevopt="-dlopen" prev=execute_dlfiles ;; -*) $echo "$modename: unrecognized option \`$arg'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; *) nonopt="$arg" break ;; esac done if test -n "$prevopt"; then $echo "$modename: option \`$prevopt' requires an argument" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi case $disable_libs in no) ;; shared) build_libtool_libs=no build_old_libs=yes ;; static) build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` ;; esac # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= if test -z "$show_help"; then # Infer the operation mode. if test -z "$mode"; then $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2 case $nonopt in *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) mode=link for arg do case $arg in -c) mode=compile break ;; esac done ;; *db | *dbx | *strace | *truss) mode=execute ;; *install*|cp|mv) mode=install ;; *rm) mode=uninstall ;; *) # If we have no mode, but dlfiles were specified, then do execute mode. test -n "$execute_dlfiles" && mode=execute # Just use the default operation mode. if test -z "$mode"; then if test -n "$nonopt"; then $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 else $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 fi fi ;; esac fi # Only execute mode is allowed to have -dlopen flags. if test -n "$execute_dlfiles" && test "$mode" != execute; then $echo "$modename: unrecognized option \`-dlopen'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$modename --help --mode=$mode' for more information." # These modes are in order of execution frequency so that they run quickly. case $mode in # libtool compile mode compile) modename="$modename: compile" # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= 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) if test -n "$libobj" ; then $echo "$modename: you cannot specify \`-o' more than once" 1>&2 exit $EXIT_FAILURE fi arg_mode=target continue ;; -static | -prefer-pic | -prefer-non-pic) later="$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,*) args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac lastarg="$lastarg $arg" done IFS="$save_ifs" lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` # Add the arguments to base_compile. base_compile="$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. lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` case $lastarg in # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, and some SunOS ksh mistreat backslash-escaping # in scan sets (worked around with variable expansion), # and furthermore cannot handle '|' '&' '(' ')' in scan sets # at all, so we specify them separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") lastarg="\"$lastarg\"" ;; esac base_compile="$base_compile $lastarg" done # for arg case $arg_mode in arg) $echo "$modename: you must specify an argument for -Xcompile" exit $EXIT_FAILURE ;; target) $echo "$modename: you must specify a target with \`-o'" 1>&2 exit $EXIT_FAILURE ;; *) # Get the name of the library object. [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo xform='[cCFSifmso]' case $libobj in *.ada) xform=ada ;; *.adb) xform=adb ;; *.ads) xform=ads ;; *.asm) xform=asm ;; *.c++) xform=c++ ;; *.cc) xform=cc ;; *.ii) xform=ii ;; *.class) xform=class ;; *.cpp) xform=cpp ;; *.cxx) xform=cxx ;; *.f90) xform=f90 ;; *.for) xform=for ;; *.java) xform=java ;; esac libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` case $libobj in *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; *) $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 exit $EXIT_FAILURE ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -static) build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"` case $qlibobj in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qlibobj="\"$qlibobj\"" ;; esac test "X$libobj" != "X$qlibobj" \ && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \ && $echo "$modename: libobj name \`$libobj' may not contain shell special characters." objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$obj"; then xdir= else xdir=$xdir/ fi lobj=${xdir}$objdir/$objname if test -z "$base_compile"; then $echo "$modename: you must specify a compilation command" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # 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 $run $rm $removelist trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" removelist="$removelist $output_obj $lockfile" trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 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 $run ln "$progpath" "$lockfile" 2>/dev/null; do $show "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $echo "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit $EXIT_FAILURE fi $echo "$srcfile" > "$lockfile" fi if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"` case $qsrcfile in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qsrcfile="\"$qsrcfile\"" ;; esac $run $rm "$libobj" "${libobj}T" # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. test -z "$run" && cat > ${libobj}T <<EOF # $libobj - a libtool object file # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # Please DO NOT delete this file! # It is necessary for linking the library. # Name of the PIC object. EOF # 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 if test ! -d "${xdir}$objdir"; then $show "$mkdir ${xdir}$objdir" $run $mkdir ${xdir}$objdir exit_status=$? if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then exit $exit_status fi fi if test -z "$output_obj"; then # Place PIC objects in $objdir command="$command -o $lobj" fi $run $rm "$lobj" "$output_obj" $show "$command" if $run eval "$command"; then : else test -n "$output_obj" && $run $rm $removelist exit $EXIT_FAILURE fi if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit $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 $show "$mv $output_obj $lobj" if $run $mv $output_obj $lobj; then : else error=$? $run $rm $removelist exit $error fi fi # Append the name of the PIC object to the libtool object file. test -z "$run" && cat >> ${libobj}T <<EOF pic_object='$objdir/$objname' EOF # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi else # No PIC object so indicate it doesn't exist in the libtool # object file. test -z "$run" && cat >> ${libobj}T <<EOF pic_object=none EOF 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" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then command="$command -o $obj" fi # Suppress compiler output if we already did a PIC compilation. command="$command$suppress_output" $run $rm "$obj" "$output_obj" $show "$command" if $run eval "$command"; then : else $run $rm $removelist exit $EXIT_FAILURE fi if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then $show "$mv $output_obj $obj" if $run $mv $output_obj $obj; then : else error=$? $run $rm $removelist exit $error fi fi # Append the name of the non-PIC object the libtool object file. # Only append if the libtool object file exists. test -z "$run" && cat >> ${libobj}T <<EOF # Name of the non-PIC object. non_pic_object='$objname' EOF else # Append the name of the non-PIC object the libtool object file. # Only append if the libtool object file exists. test -z "$run" && cat >> ${libobj}T <<EOF # Name of the non-PIC object. non_pic_object=none EOF fi $run $mv "${libobj}T" "${libobj}" # Unlock the critical section if it was locked if test "$need_locks" != no; then $run $rm "$lockfile" fi exit $EXIT_SUCCESS ;; # libtool link mode link | relink) modename="$modename: link" case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool 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= avoid_version=no dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= notinst_path= # paths that contain not-installed libtool libraries 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 func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -all-static | -static) if test "X$arg" = "X-all-static"; then if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes else if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built fi 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 case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test ;; *) qarg=$arg ;; esac libtool_args="$libtool_args $qarg" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) compile_command="$compile_command @OUTPUT@" finalize_command="$finalize_command @OUTPUT@" ;; esac case $prev in dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. compile_command="$compile_command @SYMFILE@" finalize_command="$finalize_command @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then dlfiles="$dlfiles $arg" else dlprefiles="$dlprefiles $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" if test ! -f "$arg"; then $echo "$modename: symbol file \`$arg' does not exist" exit $EXIT_FAILURE fi prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat $save_arg` do # moreargs="$moreargs $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then pic_object= non_pic_object= # Read the .lo file # If there is no directory component, then add one. case $arg in */* | *\\*) . $arg ;; *) . ./$arg ;; esac if test -z "$pic_object" || \ test -z "$non_pic_object" || test "$pic_object" = none && \ test "$non_pic_object" = none; then $echo "$modename: cannot find name of object for \`$arg'" 1>&2 exit $EXIT_FAILURE fi # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi 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 dlfiles="$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. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. libobjs="$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 non_pic_objects="$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" non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. if test -z "$run"; then $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 exit $EXIT_FAILURE else # Dry-run case. # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` libobjs="$libobjs $pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi fi done else $echo "$modename: link input file \`$save_arg' does not exist" exit $EXIT_FAILURE fi arg=$save_arg prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit $EXIT_FAILURE ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) xrpath="$xrpath $arg" ;; esac fi prev= continue ;; xcompiler) compiler_flags="$compiler_flags $qarg" prev= compile_command="$compile_command $qarg" finalize_command="$finalize_command $qarg" continue ;; xlinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $wl$qarg" prev= compile_command="$compile_command $wl$qarg" finalize_command="$finalize_command $wl$qarg" continue ;; xcclinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $qarg" prev= compile_command="$compile_command $qarg" finalize_command="$finalize_command $qarg" continue ;; shrext) shrext_cmds="$arg" prev= continue ;; darwin_framework|darwin_framework_skip) test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" prev= continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then compile_command="$compile_command $link_static_flag" finalize_command="$finalize_command $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 continue ;; -avoid-version) avoid_version=yes continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: more than one -exported-symbols argument is not allowed" exit $EXIT_FAILURE fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework|-arch|-isysroot) case " $CC " in *" ${arg} ${1} "* | *" ${arg} ${1} "*) prev=darwin_framework_skip ;; *) compiler_flags="$compiler_flags $arg" prev=darwin_framework ;; esac compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" 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*) compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" ;; esac continue ;; -L*) dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 absdir="$dir" notinst_path="$notinst_path $dir" fi dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "*) ;; *) deplibs="$deplibs -L$dir" lib_search_path="$lib_search_path $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; *) dllsearchpath="$dllsearchpath:$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; *) dllsearchpath="$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*) # 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 deplibs="$deplibs -framework System" 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 deplibs="$deplibs $arg" continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. -model) compile_command="$compile_command $arg" compiler_flags="$compiler_flags $arg" finalize_command="$finalize_command $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) compiler_flags="$compiler_flags $arg" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" continue ;; -module) module=yes continue ;; # -64, -mips[0-9] enable 64-bit mode on the SGI compiler # -r[0-9][0-9]* specifies the processor on the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler # +DA*, +DD* enable 64-bit mode on the HP compiler # -q* pass through compiler args for the IBM compiler # -m* pass through architecture-specific compiler args for GCC # -m*, -t[45]*, -txscale* pass through architecture-specific # compiler args for GCC # -pg pass through profiling flag for GCC # @file GCC response files -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \ -t[45]*|-txscale*|@*) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" compiler_flags="$compiler_flags $arg" continue ;; -shrext) prev=shrext continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) # The PATH hackery in wrapper scripts is required on Windows # in order for the loader to find any dlls it needs. $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -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*) dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit $EXIT_FAILURE ;; esac case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac continue ;; -static) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -Wc,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Wl,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $wl$flag" linker_flags="$linker_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # Some other compiler flag. -* | +*) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; *.$objext) # A standard object. objs="$objs $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then pic_object= non_pic_object= # Read the .lo file # If there is no directory component, then add one. case $arg in */* | *\\*) . $arg ;; *) . ./$arg ;; esac if test -z "$pic_object" || \ test -z "$non_pic_object" || test "$pic_object" = none && \ test "$non_pic_object" = none; then $echo "$modename: cannot find name of object for \`$arg'" 1>&2 exit $EXIT_FAILURE fi # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi 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 dlfiles="$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. dlprefiles="$dlprefiles $pic_object" prev= fi # A PIC object. libobjs="$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 non_pic_objects="$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" non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. if test -z "$run"; then $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 exit $EXIT_FAILURE else # Dry-run case. # Extract subdirectory from the argument. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$arg"; then xdir= else xdir="$xdir/" fi pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` libobjs="$libobjs $pic_object" non_pic_objects="$non_pic_objects $non_pic_object" fi fi ;; *.$libext) # An archive. deplibs="$deplibs $arg" old_deplibs="$old_deplibs $arg" continue ;; *.la) # A libtool-controlled library. if test "$prev" = dlfiles; then # This library was specified with -dlopen. dlfiles="$dlfiles $arg" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. dlprefiles="$dlprefiles $arg" prev= else deplibs="$deplibs $arg" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi done # argument parsing loop if test -n "$prev"; then $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi oldlibs= # calculate the name of the file, without its directory outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` if test "X$output_objdir" = "X$output"; then output_objdir="$objdir" else output_objdir="$output_objdir/$objdir" fi # Create the object directory. if test ! -d "$output_objdir"; then $show "$mkdir $output_objdir" $run $mkdir $output_objdir exit_status=$? if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then exit $exit_status fi fi # Determine the type of output case $output in "") $echo "$modename: you must specify an output file" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac case $host in *cygwin* | *mingw* | *pw32*) # don't eliminate duplications in $postdeps and $predeps duplicate_compiler_generated_deps=yes ;; *) duplicate_compiler_generated_deps=$duplicate_deps ;; esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if test "X$duplicate_deps" = "Xyes" ; then case "$libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi libs="$libs $deplib" done 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 test "X$duplicate_compiler_generated_deps" = "Xyes" ; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; esac pre_post_deps="$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 case $linkmode in lib) passes="conv link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 exit $EXIT_FAILURE ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do if test "$linkmode,$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% $dependency_libs" ;; esac 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) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else compiler_flags="$compiler_flags $deplib" fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 continue fi name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do 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 (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then library_names= old_library= case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac 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 ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` test "X$ladir" = "X$lib" && ladir="." 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 -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` ;; *) $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) lib="$deplib" ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` 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 used here." else $echo $echo "*** Warning: Linking the shared library $output against the" $echo "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = 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. newdlprefiles="$newdlprefiles $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else newdlfiles="$newdlfiles $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2 exit $EXIT_FAILURE fi # Check to see that this really is a libtool archive. if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` test "X$ladir" = "X$lib" && ladir="." dlname= dlopen= dlpreopen= libdir= library_names= old_library= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit $EXIT_FAILURE fi # It is a libtool convenience library, so add in its objects. convenience="$convenience $ladir/$objdir/$old_library" old_convenience="$old_convenience $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then $echo "$modename: \`$lib' is not a convenience library" 1>&2 exit $EXIT_FAILURE fi continue fi # $pass = conv # Get the name of the library we link against. linklib= for l in $old_library $library_names; do linklib="$l" done if test -z "$linklib"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit $EXIT_FAILURE fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 exit $EXIT_FAILURE 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. dlprefiles="$dlprefiles $lib $dependency_libs" else newdlfiles="$newdlfiles $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 abs_ladir="$ladir" fi ;; esac laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then $echo "$modename: warning: library \`$lib' was moved." 1>&2 dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$libdir" absdir="$libdir" fi 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 notinst_path="$notinst_path $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" fi fi # $installed = yes name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 exit $EXIT_FAILURE fi # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then newdlprefiles="$newdlprefiles $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then newdlprefiles="$newdlprefiles $dir/$dlname" else newdlprefiles="$newdlprefiles $dir/$linklib" fi fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { test "$prefer_static_libs" = no || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath " in *" $dir "*) ;; *" $absdir "*) ;; *) temp_rpath="$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 "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi # $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 if test "$installed" = no; then notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi # This is a shared library # Warn about portability, can't link against -module's on # some systems (darwin) if 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 "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names realname="$2" shift; shift libname=`eval \\$echo \"$libname_spec\"` # 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*) major=`expr $current - $age` versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" soname=`$echo $soroot | ${SED} -e 's/^.*\///'` newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else $show "extracting exported symbol list from \`$soname'" save_ifs="$IFS"; IFS='~' cmds=$extract_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else $show "generating import library for \`$soname'" save_ifs="$IFS"; IFS='~' cmds=$old_archive_from_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" 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 module then we can not link against # it, someone is ignoring the new warnings I added if /usr/bin/file -L $add 2> /dev/null | $EGREP ": [^:]* bundle" >/dev/null ; 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 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; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) add_dir="$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 $echo "$modename: configuration error: unsupported hardcode properties" exit $EXIT_FAILURE fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && \ test "$hardcode_minus_L" != yes && \ test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" 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 [\\/]*) add_dir="$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*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` case " $xrpath " in *" $temp_xrpath "*) ;; *) xrpath="$xrpath $temp_xrpath";; esac;; *) temp_deplibs="$temp_deplibs $libdir";; esac done dependency_libs="$temp_deplibs" fi newlib_search_path="$newlib_search_path $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do case $deplib in -L*) path="$deplib" ;; *.la) dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$deplib" && dir="." # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 absdir="$dir" fi ;; esac if grep "^installed=no" $deplib > /dev/null; then path="$absdir/$objdir" else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi if test "$absdir" != "$libdir"; then $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 fi path="$absdir" fi depdepl= case $host in *-*-darwin*) # we do not want to link against static libs, # but need to link against shared 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 "$path/$depdepl" ; then depdepl="$path/$depdepl" fi # do not add paths which are already there case " $newlib_search_path " in *" $path "*) ;; *) newlib_search_path="$newlib_search_path $path";; esac fi path="" ;; *) path="-L$path" ;; esac ;; -l*) case $host in *-*-darwin*) # Again, we only want to link against shared libraries eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` for tmp in $newlib_search_path ; do if test -f "$tmp/lib$tmp_libs.dylib" ; then eval depdepl="$tmp/lib$tmp_libs.dylib" break fi done path="" ;; *) continue ;; esac ;; *) continue ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac case " $deplibs " in *" $depdepl "*) ;; *) deplibs="$depdepl $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs 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 "*) ;; *) lib_search_path="$lib_search_path $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # 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 "*) ;; *) tmp_libs="$tmp_libs $deplib" ;; esac ;; *) tmp_libs="$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 tmp_libs="$tmp_libs $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$deplibs"; then $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 fi if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 fi if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 fi # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" objs="$objs$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) if test "$module" = no; then $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 exit $EXIT_FAILURE else $echo $echo "*** Warning: Linking the shared library $output against the non-libtool" $echo "*** objects $objs is not portable!" libobjs="$libobjs $objs" fi fi if test "$dlself" != no; then $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 fi set dummy $rpath if test "$#" -gt 2; then $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 fi install_libdir="$2" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # 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 if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 fi else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 IFS="$save_ifs" if test -n "$8"; then $echo "$modename: too many parameters to \`-version-info'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # 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="$2" number_minor="$3" number_revision="$4" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in darwin|linux|osf|windows) current=`expr $number_major + $number_minor` age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) current=`expr $number_major + $number_minor - 1` age="$number_minor" revision="$number_minor" ;; esac ;; no) current="$2" revision="$3" age="$4" ;; 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]) ;; *) $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; 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]) ;; *) $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; 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]) ;; *) $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE ;; esac if test "$age" -gt "$current"; then $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit $EXIT_FAILURE fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header major=.`expr $current - $age` versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... minor_current=`expr $current + 1` verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current"; ;; irix | nonstopux) major=`expr $current - $age + 1` case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do iface=`expr $revision - $loop` loop=`expr $loop - 1` verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) major=.`expr $current - $age` versuffix="$major.$age.$revision" ;; osf) major=.`expr $current - $age` versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do iface=`expr $current - $loop` loop=`expr $loop - 1` verstring="$verstring:${iface}.0" done # Make executables depend on our current version. verstring="$verstring:${current}.0" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. major=`expr $current - $age` versuffix="-$major" ;; *) $echo "$modename: unknown library version type \`$version_type'" 1>&2 $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit $EXIT_FAILURE ;; 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 $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi if test "$mode" != relink; then # Remove our outputs, 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) ;; $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 removelist="$removelist $p" ;; *) ;; esac done if test -n "$removelist"; then $show "${rm}r $removelist" $run ${rm}r $removelist fi fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then oldlibs="$oldlibs $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` fi # Eliminate all temporary directories. for path in $notinst_path; do lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"` deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"` dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"` done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do temp_xrpath="$temp_xrpath -R$libdir" case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) dlfiles="$dlfiles $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) dlprefiles="$dlprefiles $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework deplibs="$deplibs -framework System" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-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 deplibs="$deplibs -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the 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. $rm conftest.c cat > conftest.c <<EOF int main() { return 0; } EOF $rm conftest $LTCC $LTCFLAGS -o conftest conftest.c $deplibs if test "$?" -eq 0 ; then ldd_output=`ldd conftest` for i in $deplibs; do name=`expr $i : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test "$name" != "" && test "$name" -ne "0"; then if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $i "*) newdeplibs="$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 deplib_match=$2 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then newdeplibs="$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 else newdeplibs="$newdeplibs $i" fi 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 name=`expr $i : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test "$name" != "" && test "$name" != "0"; then $rm conftest $LTCC $LTCFLAGS -o conftest conftest.c $i # Did it work? if test "$?" -eq 0 ; then ldd_output=`ldd conftest` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $i "*) newdeplibs="$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 deplib_match=$2 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then newdeplibs="$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 else newdeplibs="$newdeplibs $i" fi done fi ;; file_magic*) set dummy $deplibs_check_method file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` for a_deplib in $deplibs; do name=`expr $a_deplib : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test "$name" != "" && test "$name" != "0"; then if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) newdeplibs="$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 # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null \ | grep " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ | ${SED} 10q \ | $EGREP "$file_magic_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done 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 else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` for a_deplib in $deplibs; do name=`expr $a_deplib : '-l\(.*\)'` # If $name is empty we are operating on a -L argument. if test -n "$name" && test "$name" != "0"; then if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) newdeplibs="$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 newdeplibs="$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 else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ -e '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 "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` done fi if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ | grep . >/dev/null; then $echo if test "X$deplibs_check_method" = "Xnone"; then $echo "*** Warning: inter-library dependencies are not supported in this platform." else $echo "*** Warning: inter-library dependencies are not known to be supported." fi $echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes fi ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then $echo $echo "*** Warning: libtool could not satisfy all declared inter-library" $echo "*** dependencies of module $libname. Therefore, libtool will create" $echo "*** a static module, that should work as long as the dlopening" $echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then $echo $echo "*** However, this would only work if libtool was able to extract symbol" $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" $echo "*** not find such a program. So, this module is probably useless." $echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else $echo "*** The inter-library dependencies that have been dropped here will be" $echo "*** automatically added whenever a program is linked with this library" $echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then $echo $echo "*** Since this library must not contain undefined symbols," $echo "*** because either the platform does not support them or" $echo "*** it was explicitly requested with -no-undefined," $echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # 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 "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" if test -n "$hardcode_libdir_flag_spec_ld"; then eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" else eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names realname="$2" shift; shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do linknames="$linknames $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then $show "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $run $rm $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" if len=`expr "X$cmd" : ".*"` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then $show "$cmd" $run eval "$cmd" || exit $? skipped_export=false else # The command line is too long to execute in one step. $show "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"; then $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' $show "$mv \"${export_symbols}T\" \"$export_symbols\"" $run eval '$mv "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) tmp_deplibs="$tmp_deplibs $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" else gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $convenience libobjs="$libobjs $func_extract_archives_result" fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" linker_flags="$linker_flags $flag" fi # Make a backup of the uninstalled library when relinking if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$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:" && len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise. $echo "creating reloadable object files..." # 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 output_la=`$echo "X$output" | $Xsed -e "$basename"` # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= delfiles= last_robj= k=1 output=$output_objdir/$output_la-${k}.$objext # Loop over the list of objects to be linked. for obj in $save_libobjs do eval test_cmds=\"$reload_cmds $objlist $last_robj\" if test "X$objlist" = X || { len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$max_cmd_len"; }; then objlist="$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. eval concat_cmds=\"$reload_cmds $objlist $last_robj\" else # All subsequent reloadable object files will link in # the last one created. eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext k=`expr $k + 1` output=$output_objdir/$output_la-${k}.$objext objlist=$obj len=1 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~ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" if ${skipped_export-false}; then $show "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $run $rm $export_symbols libobjs=$output # Append the command to create the export file. eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" fi # Set up a command to remove the reloadable object files # after they are used. i=0 while test "$i" -lt "$k" do i=`expr $i + 1` delfiles="$delfiles $output_objdir/$output_la-${i}.$objext" done $echo "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" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" 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\" 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 # Append the command to remove the reloadable object files # to the just-reset $cmds. eval cmds=\"\$cmds~\$rm $delfiles\" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(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 "$mode" = relink; then $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 $show "${rm}r $gentop" $run ${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 $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$deplibs"; then $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 fi if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 fi case $output in *.lo) if test -n "$objs$old_deplibs"; then $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 exit $EXIT_FAILURE fi libobj="$output" obj=`$echo "X$output" | $Xsed -e "$lo2o"` ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $run $rm $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" else gentop="$output_objdir/${obj}x" generated="$generated $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # Create the old-style object. reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" cmds=$reload_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $run eval "echo timestamp > $libobj" || exit $? exit $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" cmds=$reload_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; esac if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 fi if test "$preload" = yes; then if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && test "$dlopen_self_static" = unknown; then $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." fi fi case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac case $host in *darwin*) # Don't allow lazy linking, it breaks C++ global constructors if test "$tagname" = CXX ; then compile_command="$compile_command ${wl}-bind_at_load" finalize_command="$finalize_command ${wl}-bind_at_load" fi ;; 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 "*) new_libs="$new_libs -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$new_libs $deplib" ;; esac ;; *) new_libs="$new_libs $deplib" ;; esac done compile_deplibs="$new_libs" compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; *) dllsearchpath="$dllsearchpath:$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; *) dllsearchpath="$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"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` fi dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then dlsyms="${outputname}S.c" else $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 fi fi if test -n "$dlsyms"; then case $dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${outputname}.nm" $show "$rm $nlist ${nlist}S ${nlist}T" $run $rm "$nlist" "${nlist}S" "${nlist}T" # Parse the name list into a source file. $show "creating $output_objdir/$dlsyms" test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ /* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ /* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ #ifdef __cplusplus extern \"C\" { #endif /* Prevent the only kind of declaration conflicts we can make. */ #define lt_preloaded_symbols some_other_symbol /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then $show "generating symbol list for \`$output'" test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` for arg in $progfiles; do $show "extracting global C symbols from \`$arg'" $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi if test -n "$export_symbols_regex"; then $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $run $rm $export_symbols $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* ) $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac else $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' $run eval 'mv "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* ) $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac fi fi for arg in $dlprefiles; do $show "extracting global C symbols from \`$arg'" name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` $run eval '$echo ": $name " >> "$nlist"' $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -z "$run"; then # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $mv "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if grep -v "^: " < "$nlist" | if sort -k 3 </dev/null >/dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else grep -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' else $echo '/* NONE */' >> "$output_objdir/$dlsyms" fi $echo >> "$output_objdir/$dlsyms" "\ #undef lt_preloaded_symbols #if defined (__STDC__) && __STDC__ # define lt_ptr void * #else # define lt_ptr char * # define const #endif /* The mapping between symbol names and symbols. */ " case $host in *cygwin* | *mingw* ) $echo >> "$output_objdir/$dlsyms" "\ /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs */ struct { " ;; * ) $echo >> "$output_objdir/$dlsyms" "\ const struct { " ;; esac $echo >> "$output_objdir/$dlsyms" "\ const char *name; lt_ptr address; } lt_preloaded_symbols[] = {\ " eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" $echo >> "$output_objdir/$dlsyms" "\ {0, (lt_ptr) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " fi pic_flag_for_symtable= case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; esac;; *-*-hpux*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag";; esac esac # Now compile the dynamic symbol file. $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? # Clean up the generated files. $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" # Transform the symbol file into the correct name. case $host in *cygwin* | *mingw* ) if test -f "$output_objdir/${outputname}.def" ; then compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"` finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"` else compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` fi ;; * ) compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` ;; esac ;; *) $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 exit $EXIT_FAILURE ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` fi if test "$need_relink" = no || test "$build_libtool_libs" != yes; then # Replace the output file specification. compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. $show "$link_command" $run eval "$link_command" exit_status=$? # Delete the generated files. if test -n "$dlsyms"; then $show "$rm $output_objdir/${outputname}S.${objext}" $run $rm "$output_objdir/${outputname}S.${objext}" fi exit $exit_status fi if test -n "$shlibpath_var"; then # We should set the shlibpath_var rpath= for dir in $temp_rpath; do case $dir in [\\/]* | [A-Za-z]:[\\/]*) # Absolute path. rpath="$rpath$dir:" ;; *) # Relative path: add a thisdir entry. rpath="$rpath\$thisdir/$dir:" ;; esac done temp_rpath="$rpath" fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do rpath="$rpath$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $run $rm $output # Link the executable and exit $show "$link_command" $run eval "$link_command" || exit $? exit $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" $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 $echo "$modename: \`$output' will be relinked during installation" 1>&2 else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname $show "$link_command" $run eval "$link_command" || exit $? # Now create the wrapper script. $show "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` fi # Quote $echo for shipping. if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then case $progpath in [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; esac qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` else qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` fi # Only actually do things if our run command is non-null. if test -z "$run"; then # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) output_name=`basename $output` output_path=`dirname $output` 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 cat > $cwrappersource <<EOF /* $cwrappersource - temporary wrapper executable for $objdir/$outputname Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP The $output program cannot be directly executed until all the libtool libraries that it depends on are installed. This wrapper executable should never be moved out of the build directory. If it is, it will not operate correctly. Currently, it simply execs the wrapper *script* "/bin/sh $output", but could eventually absorb all of the scripts functionality and exec $objdir/$outputname directly. */ EOF cat >> $cwrappersource<<"EOF" #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <malloc.h> #include <stdarg.h> #include <assert.h> #include <string.h> #include <ctype.h> #include <sys/stat.h> #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #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 # 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 */ #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) /* -DDEBUG is fairly common in CFLAGS. */ #undef DEBUG #if defined DEBUGWRAPPER # define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__) #else # define DEBUG(format, ...) #endif const char *program_name = NULL; void * xmalloc (size_t num); char * xstrdup (const char *string); const char * base_name (const char *name); char * find_executable(const char *wrapper); int check_executable(const char *path); char * strendzap(char *str, const char *pat); void lt_fatal (const char *message, ...); int main (int argc, char *argv[]) { char **newargz; int i; program_name = (char *) xstrdup (base_name (argv[0])); DEBUG("(main) argv[0] : %s\n",argv[0]); DEBUG("(main) program_name : %s\n",program_name); newargz = XMALLOC(char *, argc+2); EOF cat >> $cwrappersource <<EOF newargz[0] = (char *) xstrdup("$SHELL"); EOF cat >> $cwrappersource <<"EOF" newargz[1] = find_executable(argv[0]); if (newargz[1] == NULL) lt_fatal("Couldn't find %s", argv[0]); DEBUG("(main) found exe at : %s\n",newargz[1]); /* we know the script has the same name, without the .exe */ /* so make sure newargz[1] doesn't end in .exe */ strendzap(newargz[1],".exe"); for (i = 1; i < argc; i++) newargz[i+1] = xstrdup(argv[i]); newargz[argc+1] = NULL; for (i=0; i<argc+1; i++) { DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]); ; } EOF case $host_os in mingw*) cat >> $cwrappersource <<EOF execv("$SHELL",(char const **)newargz); EOF ;; *) cat >> $cwrappersource <<EOF execv("$SHELL",newargz); EOF ;; esac cat >> $cwrappersource <<"EOF" return 127; } void * xmalloc (size_t num) { void * p = (void *) malloc (num); if (!p) lt_fatal ("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; DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"); if ((!path) || (!*path)) return 0; if ((stat (path, &st) >= 0) && ( /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ #if defined (S_IXOTH) ((st.st_mode & S_IXOTH) == S_IXOTH) || #endif #if defined (S_IXGRP) ((st.st_mode & S_IXGRP) == S_IXGRP) || #endif ((st.st_mode & S_IXUSR) == S_IXUSR)) ) return 1; else return 0; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise */ 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; DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"); 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 ("getcwd failed"); 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 ("getcwd failed"); 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 * 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; } static void lt_error_core (int exit_status, const char * mode, const char * message, va_list ap) { fprintf (stderr, "%s: %s: ", program_name, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, "FATAL", message, ap); va_end (ap); } EOF # we should really use a build-platform specific compiler # here, but OTOH, the wrappers (shell script and this C one) # are only useful if you want to execute the "real" binary. # Since the "real" binary is built for $host, then this # wrapper might as well be built for $host, too. $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource ;; esac $rm $output trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 $echo > $output "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='${SED} -e 1s/^X//' sed_quote_subst='$sed_quote_subst' # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (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 variable: notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$echo are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then echo=\"$qecho\" file=\"\$0\" # Make sure echo works. if test \"X\$1\" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then # Yippee, \$echo works! : else # Restart under the correct shell, and then maybe \$echo will work. exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} fi fi\ " $echo >> $output "\ # Find the directory that this script lives in. thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` done # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $echo >> $output "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || \\ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $mkdir \"\$progdir\" else $rm \"\$progdir/\$file\" fi" $echo >> $output "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $echo \"\$relink_command_output\" >&2 $rm \"\$progdir/\$file\" exit $EXIT_FAILURE fi fi $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $rm \"\$progdir/\$program\"; $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } $rm \"\$progdir/\$file\" fi" else $echo >> $output "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $echo >> $output "\ if test -f \"\$progdir/\$program\"; then" # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $echo >> $output "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` export $shlibpath_var " fi # fixup the dll searchpath if we need to. if test -n "$dllsearchpath"; then $echo >> $output "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi $echo >> $output "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2*) $echo >> $output "\ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $echo >> $output "\ exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $echo >> $output "\ \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" exit $EXIT_FAILURE 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 $EXIT_FAILURE fi fi\ " chmod +x $output fi 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" 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" fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" func_extract_archives $gentop $addlibs oldobjs="$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 # 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 $echo "X$obj" | $Xsed -e 's%^.*/%%' done | sort | sort -uc >/dev/null 2>&1); then : else $echo "copying selected object files to avoid basename conflicts..." if test -z "$gentop"; then gentop="$output_objdir/${outputname}x" generated="$generated $gentop" $show "${rm}r $gentop" $run ${rm}r "$gentop" $show "$mkdir $gentop" $run $mkdir "$gentop" exit_status=$? if test "$exit_status" -ne 0 && test ! -d "$gentop"; then exit $exit_status fi fi save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase counter=`expr $counter + 1` case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" $run ln "$obj" "$gentop/$newobj" || $run cp "$obj" "$gentop/$newobj" oldobjs="$oldobjs $gentop/$newobj" ;; *) oldobjs="$oldobjs $obj" ;; esac done fi eval cmds=\"$old_archive_cmds\" if len=`expr "X$cmds" : ".*"` && test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts $echo "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_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 for obj in $save_oldobjs do oldobjs="$objlist $obj" objlist="$objlist $obj" eval test_cmds=\"$old_archive_cmds\" if len=`expr "X$test_cmds" : ".*" 2>/dev/null` && test "$len" -le "$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= 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 save_ifs="$IFS"; IFS='~' for cmd in $cmds; do eval cmd=\"$cmd\" IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$generated"; then $show "${rm}r$generated" $run ${rm}r$generated fi # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" $show "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. if test -z "$run"; then for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi newdependency_libs="$newdependency_libs $libdir/$name" ;; *) newdependency_libs="$newdependency_libs $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi newdlfiles="$newdlfiles $libdir/$name" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit $EXIT_FAILURE fi newdlprefiles="$newdlprefiles $libdir/$name" done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlfiles="$newdlfiles $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac newdlprefiles="$newdlprefiles $abs" done dlprefiles="$newdlprefiles" fi $rm $output # place dlname in correct position for cygwin tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; esac $echo > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # 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 fi # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? ;; esac exit $EXIT_SUCCESS ;; # libtool install mode install) modename="$modename: install" # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. $echo "X$nonopt" | grep shtool > /dev/null; then # Aesthetically quote it. arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac install_prog="$arg " arg="$1" shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac install_prog="$install_prog$arg" # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= for arg do if test -n "$dest"; then files="$files $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) case " $install_prog " in *[\\\ /]cp\ *) ;; *) prev=$arg ;; esac ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac install_prog="$install_prog $arg" done if test -z "$install_prog"; then $echo "$modename: you must specify an install program" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test -n "$prev"; then $echo "$modename: the \`$prev' option requires an argument" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi if test -z "$files"; then if test -z "$dest"; then $echo "$modename: no file or destination specified" 1>&2 else $echo "$modename: you must specify a destination" 1>&2 fi $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Strip any trailing slash from the destination. dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` test "X$destdir" = "X$dest" && destdir=. destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` # Not a directory, so check to see that there is only one file specified. set dummy $files if test "$#" -gt 2; then $echo "$modename: \`$dest' is not a directory" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. staticlibs="$staticlibs $file" ;; *.la) # Check to see that this really is a libtool archive. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi library_names= old_library= relink_command= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) future_libdirs="$future_libdirs $libdir" ;; esac fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ test "X$dir" = "X$file/" && dir= dir="$dir$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$echo "$destdir" | $SED "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. if test "$inst_prefix_dir" = "$destdir"; then $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 exit $EXIT_FAILURE fi 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 $echo "$modename: warning: relinking \`$file'" 1>&2 $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 exit $EXIT_FAILURE fi fi # See the names of the shared library. set dummy $library_names if test -n "$2"; then realname="$2" shift shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. $show "$install_prog $dir/$srcname $destdir/$realname" $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? if test -n "$stripme" && test -n "$striplib"; then $show "$striplib $destdir/$realname" $run eval "$striplib $destdir/$realname" || exit $? fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # 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 if test "$linkname" != "$realname"; then $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })" fi done fi # Do each command in the postinstall commands. lib="$destdir/$realname" cmds=$postinstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)' fi exit $lt_exit } done IFS="$save_ifs" fi # Install the pseudo-library for information purposes. name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` instname="$dir/$name"i $show "$install_prog $instname $destdir/$name" $run eval "$install_prog $instname $destdir/$name" || exit $? # Maybe install the static library, too. test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` ;; *.$objext) staticdest="$destfile" destfile= ;; *) $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; esac # Install the libtool object if requested. if test -n "$destfile"; then $show "$install_prog $file $destfile" $run eval "$install_prog $file $destfile" || exit $? fi # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` $show "$install_prog $staticobj $staticdest" $run eval "$install_prog \$staticobj \$staticdest" || exit $? fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # 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 file=`$echo $file|${SED} 's,.exe$,,'` stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin*|*mingw*) wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` ;; *) wrapper=$file ;; esac if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then notinst_deplibs= relink_command= # Note that it is not necessary on cygwin/mingw to append a dot to # foo even if both foo 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. # # If there is no directory component, then add one. case $wrapper in */* | *\\*) . ${wrapper} ;; *) . ./${wrapper} ;; esac # Check the variables that should have been set. if test -z "$notinst_deplibs"; then $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 exit $EXIT_FAILURE fi finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then # If there is no directory component, then add one. case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac fi libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 finalize=no fi done relink_command= # Note that it is not necessary on cygwin/mingw to append a dot to # foo even if both foo 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. # # If there is no directory component, then add one. case $wrapper in */* | *\\*) . ${wrapper} ;; *) . ./${wrapper} ;; esac outputname= if test "$fast_install" = no && test -n "$relink_command"; then if test "$finalize" = yes && test -z "$run"; then tmpdir=`func_mktempdir` file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 ${rm}r "$tmpdir" continue fi file="$outputname" else $echo "$modename: warning: cannot relink \`$file'" 1>&2 fi else # Install the binary that we compiled earlier. file=`$echo "X$file$stripped_ext" | $Xsed -e "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) destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` ;; esac ;; esac $show "$install_prog$stripme $file $destfile" $run eval "$install_prog\$stripme \$file \$destfile" || exit $? test -n "$outputname" && ${rm}r "$tmpdir" ;; esac done for file in $staticlibs; do name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` # Set up the ranlib parameters. oldlib="$destdir/$name" $show "$install_prog $file $oldlib" $run eval "$install_prog \$file \$oldlib" || exit $? if test -n "$stripme" && test -n "$old_striplib"; then $show "$old_striplib $oldlib" $run eval "$old_striplib $oldlib" || exit $? fi # Do each command in the postinstall commands. cmds=$old_postinstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$future_libdirs"; then $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 fi if test -n "$current_libdirs"; then # Maybe just do a dry run. test -n "$run" && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi ;; # libtool finish mode finish) modename="$modename: finish" libdirs="$nonopt" admincmds= if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for dir do libdirs="$libdirs $dir" done for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. cmds=$finish_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || admincmds="$admincmds $cmd" done IFS="$save_ifs" fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $run eval "$cmds" || admincmds="$admincmds $cmds" fi done fi # Exit here if they wanted silent mode. test "$show" = : && exit $EXIT_SUCCESS $echo "X----------------------------------------------------------------------" | $Xsed $echo "Libraries have been installed in:" for libdir in $libdirs; do $echo " $libdir" done $echo $echo "If you ever happen to want to link against installed libraries" $echo "in a given directory, LIBDIR, you must either use libtool, and" $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" $echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" $echo " during execution" fi if test -n "$runpath_var"; then $echo " - add LIBDIR to the \`$runpath_var' environment variable" $echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $echo " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $echo " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi $echo $echo "See any operating system documentation about shared libraries for" $echo "more information, such as the ld(1) and ld.so(8) manual pages." $echo "X----------------------------------------------------------------------" | $Xsed exit $EXIT_SUCCESS ;; # libtool execute mode execute) modename="$modename: execute" # The first argument is the command name. cmd="$nonopt" if test -z "$cmd"; then $echo "$modename: you must specify a COMMAND" 1>&2 $echo "$help" exit $EXIT_FAILURE fi # Handle -dlopen flags immediately. for file in $execute_dlfiles; do if test ! -f "$file"; then $echo "$modename: \`$file' is not a file" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi dir= case $file in *.la) # Check to see that this really is a libtool archive. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi # Read the libtool library. dlname= library_names= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" continue fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. if test -f "$dir/$objdir/$dlname"; then dir="$dir/$objdir" else $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 exit $EXIT_FAILURE fi ;; *.lo) # Just add the directory containing the .lo file. dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. ;; *) $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -*) ;; *) # Do a test to see if this is really a libtool program. if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` args="$args \"$file\"" done if test -z "$run"; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables if test "${save_LC_ALL+set}" = set; then LC_ALL="$save_LC_ALL"; export LC_ALL fi if test "${save_LANG+set}" = set; then LANG="$save_LANG"; export LANG fi # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" $echo "export $shlibpath_var" fi $echo "$cmd$args" exit $EXIT_SUCCESS fi ;; # libtool clean and uninstall mode clean | uninstall) modename="$modename: $mode" rm="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) rm="$rm $arg"; rmforce=yes ;; -*) rm="$rm $arg" ;; *) files="$files $arg" ;; esac done if test -z "$rm"; then $echo "$modename: you must specify an RM program" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE fi rmdirs= origobjdir="$objdir" for file in $files; do dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` if test "X$dir" = "X$file"; then dir=. objdir="$origobjdir" else objdir="$dir/$origobjdir" fi name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` test "$mode" = uninstall && objdir="$dir" # Remember objdir for removal later, being careful to avoid duplicates if test "$mode" = clean; then case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if (test -L "$file") >/dev/null 2>&1 \ || (test -h "$file") >/dev/null 2>&1 \ || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then . $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" case "$mode" in clean) case " $library_names " in # " " in the beginning catches empty $dlname *" $dlname "*) ;; *) rmfiles="$rmfiles $objdir/$dlname" ;; esac test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. cmds=$postuninstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" if test "$?" -ne 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. cmds=$old_postuninstall_cmds save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" if test "$?" -ne 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # Read the .lo file . $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" \ && test "$pic_object" != none; then rmfiles="$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 rmfiles="$rmfiles $dir/$non_pic_object" fi fi ;; *) if test "$mode" = clean ; then noexename=$name case $file in *.exe) file=`$echo $file|${SED} 's,.exe$,,'` noexename=`$echo $name|${SED} 's,.exe$,,'` # $file with .exe has already been added to rmfiles, # add $file without .exe rmfiles="$rmfiles $file" ;; esac # Do a test to see if this is a libtool program. if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then relink_command= . $dir/$noexename # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then rmfiles="$rmfiles $objdir/lt-$name" fi if test "X$noexename" != "X$name" ; then rmfiles="$rmfiles $objdir/lt-${noexename}.c" fi fi fi ;; esac $show "$rm $rmfiles" $run $rm $rmfiles || exit_status=1 done objdir="$origobjdir" # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then $show "rmdir $dir" $run rmdir $dir >/dev/null 2>&1 fi done exit $exit_status ;; "") $echo "$modename: you must specify a MODE" 1>&2 $echo "$generic_help" 1>&2 exit $EXIT_FAILURE ;; esac if test -z "$exec_cmd"; then $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$generic_help" 1>&2 exit $EXIT_FAILURE fi fi # test -z "$show_help" if test -n "$exec_cmd"; then eval exec $exec_cmd exit $EXIT_FAILURE fi # We need to display help for each of the modes. case $mode in "") $echo \ "Usage: $modename [OPTION]... [MODE-ARG]... Provide generalized library-building support services. --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --finish same as \`--mode=finish' --help display this help message and exit --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] --quiet same as \`--silent' --silent don't print informational messages --tag=TAG use configuration variables from tag TAG --version print version information MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for a more detailed description of MODE. Report bugs to <bug-libtool@gnu.org>." exit $EXIT_SUCCESS ;; clean) $echo \ "Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $echo \ "Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -prefer-pic try to building PIC objects only -prefer-non-pic try to building non-PIC objects only -static always build a \`.o' file suitable for static linking COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $echo \ "Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $echo \ "Usage: $modename [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $echo \ "Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $echo \ "Usage: $modename [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -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 -static do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $echo \ "Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$help" 1>&2 exit $EXIT_FAILURE ;; esac $echo $echo "Try \`$modename --help' for more information about other modes." exit $? # 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 disable_libs=shared # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static disable_libs=static # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: 07070100000012000081ED0000000000000000000000015F527092000003FC000000000000000000000000000000000000002D00000000biosdevname-0.7.3.7.g495ab76/make_release.sh#!/bin/sh # vim:et:ai:ts=4:sw=4:filetype=sh:tw=0: set -x cur_dir=$(cd $(dirname $0); pwd) cd $cur_dir/ umask 002 [ -n "$RELEASE_TOPDIR" ] || RELEASE_TOPDIR=/var/ftp/pub/linux.dell.com/srv/www/vhosts/linux.dell.com/html/files/biosdevname/ [ -n "$SIGNING_KEY" ] || SIGNING_KEY=jordan_hargrave # if anything hiccups, halt: set -e chmod -R +w _builddir ||: rm -rf _builddir mkdir _builddir pushd _builddir ../configure make -e distcheck make -e srpm chmod +x version . ./version popd git tag -u $SIGNING_KEY -m "tag for official release: $PACKAGE_STRING" v${PACKAGE_VERSION} pushd _builddir DEST=$RELEASE_TOPDIR/$PACKAGE_NAME-$PACKAGE_VERSION/ mkdir -p $DEST for i in *.tar.{gz,bz2} *.zip dist/SRPMS/*.src.rpm; do [ -e $i ] || continue [ ! -e $DEST/$(basename $i) ] || continue cp $i $DEST done # Generate GPG signature gpg -u $SIGNING_KEY --output $DEST/$PACKAGE_NAME-$PACKAGE_VERSION.tar.gz.sign --detach-sig $DEST/$PACKAGE_NAME-$PACKAGE_VERSION.tar.gz git push --tags origin master:master 07070100000013000081ED0000000000000000000000015F527092000001FB000000000000000000000000000000000000003200000000biosdevname-0.7.3.7.g495ab76/make_test_release.sh#!/bin/sh # vim:et:ai:ts=4:sw=4:filetype=sh:tw=0: set -x cur_dir=$(cd $(dirname $0); pwd) cd $cur_dir/ umask 002 # if anything hiccups, halt: set -e chmod -R +w _builddir ||: rm -rf _builddir mkdir _builddir pushd _builddir ../configure make -e distcheck make -e srpm . version popd /var/ftp/pub/yum/dell-repo/testing/_tools/upload_rpm.sh \ -c /var/ftp/pub/yum/dell-repo/testing/_tools/repo-biosdevname.cfg \ ./_builddir/dist/SRPMS/${PACKAGE_NAME}-${PACKAGE_VERSION}-*.src.rpm 07070100000014000081ED0000000000000000000000015F52709200000FBD000000000000000000000000000000000000002700000000biosdevname-0.7.3.7.g495ab76/pslots.sh#!/bin/bash # Copyright (c) 2015 Dell Inc. All Rights Reserved # # This code is released under LGPL license # # Display PCI slots for block and network devices # Display bay/ID for SSD devices declare -A dcmap function dcm() { p=$1 dcm=$2 odcm=$2 dev=0x${p:8:2} fun=0x${p:11:2} sbd=${p:0:11} pfunc=$((dev * 8 + fun)) while [ ! -z $dcm ] ;do port=${dcm:0:1} func=0x${dcm:1:1} pfi=0x${dcm:2:2} flag=0x${dcm:4:6} dcmap[$sbd${dcm:1:1}]=$odcm if [ $((func)) = $((pfunc)) ] ; then echo " p${port}_$((pfi))" fi dcm=${dcm:10} done } for Y in /sys/block/* /sys/class/net/* ; do RN=$(basename $Y) if [ ! -e $Y/device ] ; then continue fi RY=$(readlink -f $Y/device) echo ===== $RN echo " Device: $RY" if [ -e $RY/physfn ] ; then RY=$(readlink -f $RY/physfn) echo " PhysFn: $RY" fi if [ -e $Y/dev_port ] ; then DEVPORT=$(cat $Y/dev_port) echo " DevPort: $DEVPORT" fi if [ -z "$DEVPORT" ] ; then DEVPORT=0 fi FLAG="" KSLOT="" LABEL="" AINDEX="" SINDEX="" if [ -e $RY/vendor -a -e $RY/model ]; then echo -n " Vendor: " cat $RY/vendor echo -n " Model: " cat $RY/model TGT=$(basename $RY | cut -f3 -d':') if [ -e /usr/sbin/megacli ] ; then megacli -LDInfo -L$TGT -a0 | egrep "^Size|^RAID" fi fi BP="" while [ "x$RY" != "x/" ]; do P=$(basename $RY) if [ -e $RY/driver/module -a $((FLAG & 0x100)) == $((0x00)) ] ; then RM=$(readlink -f $RY/driver/module) MOD=$(basename $RM) echo " Driver: $MOD" FLAG=$((FLAG | 0x100)) fi # Only handle PCI devices if [ ! -e $RY/config ] ; then RY=$(dirname $RY) continue fi SEG=0x${P:0:4} BUS=0x${P:5:2} DEV=0x${P:8:2} FUN=0x${P:11:1} if [ -z "$BP" ] ; then BP="$((SEG)):$((BUS)):$((DEV)).$((FUN))@$((DEVPORT))" fi BUSDEV=${P:5:5} for Z in /sys/bus/pci/slots/*/address ; do if [ -e $Z ] ; then KZ=$(grep $BUSDEV $Z) if [ ! -z "$KZ" ] ; then echo " SLOTTER: $Z" fi fi done if [ -e $RY/slot -a -z "$KSLOT" ] ; then KSLOT=$(cat $RY/slot) echo " KSLOT: $KSLOT" fi if [ -e /usr/sbin/biosdecode ] ; then BDSLOT=$(biosdecode | grep "$BUSDEV.*slot" | sed -n "s/^\s*/ /p") if [ ! -z "$BDSLOT" ] ; then SBUS=$(lspci -v -s $P | sed -n "s/.*secondary=//p" | cut -f1 -d,) echo "$BDSLOT" PORT="" case "$BP" in "$((SEG)):$((BUS+2)):0.0@0"| \ "$((SEG)):$((BUS)):0.0@0") PORT=1 ;; "$((SEG)):$((BUS+2)):0.1@0"| \ "$((SEG)):$((BUS)):0.1@0"| \ "$((SEG)):$((BUS)):0.0@1") PORT=2 ;; "$((SEG)):$((BUS+3)):0.0@0"| \ "$((SEG)):$((BUS)):0.2@0") PORT=3 ;; "$((SEG)):$((BUS+3)):0.1@0"| \ "$((SEG)):$((BUS)):0.3@0") PORT=4 ;; esac echo " PORT: $PORT" fi fi CLS=$(cat $RY/class) if [ $((CLS & 0xF0000)) == $((0x10000)) ] ; then # Storage device, get bay mapping if [ -e /dev/ipmi -o -e /dev/ipmi0 ] ; then MAP=$(ipmitool raw 0x30 0xd5 0x01 0x07 0x06 0x00 0x00 0x00 $BUS 0x00 2> /dev/null) if [ "$MAP" != "" ] ; then BAY=$(echo $MAP | cut -f8 -d' ') SLOT=$(echo $MAP | cut -f9 -d' ') if [ $BAY != "fe" ] ; then echo " $P SSD bay:$BAY slot:$SLOT" fi fi fi fi if [ $((CLS & 0xF0000)) == $((0x20000)) -a -e $RY/vpd ] ; then # Network device, get DCM DCM=${dcmap[$P]} if [ -z $DCM ] ; then DCM=$(lspci -vvvv -s $P | sed -n "s/.*DCM//p") dcmap[$P]=$DCM; fi echo " DCM: $DCM" dcm $P $DCM fi if [ -e $RY/label -a -z "$LABEL" ] ; then LABEL=$(cat $RY/label) echo " $P Label: $LABEL" fi if [ -e $RY/acpi_index -a -z "$AINDEX" ] ; then AINDEX=$(cat $RY/acpi_index) echo " $P ACPI Index: $AINDEX" fi if [ -e $RY/index -a -z "$SINDEX" ] ; then SINDEX=$(cat $RY/index) echo " $P SMBIOS Index: $SINDEX" fi RY=$(dirname $RY) done done 07070100000015000041ED0000000000000000000000025F52709200000000000000000000000000000000000000000000002100000000biosdevname-0.7.3.7.g495ab76/src07070100000016000081A40000000000000000000000015F527092000002F9000000000000000000000000000000000000002D00000000biosdevname-0.7.3.7.g495ab76/src/Makefile.amINCLUDES = -I.. AM_CFLAGS = -Wall -fno-strict-aliasing man_MANS = biosdevname.1 sbin_PROGRAMS = src/biosdevname src_biosdevname_SOURCES = \ src/bios_dev_name.c \ src/bios_device.c \ src/pirq.c \ src/pci.c \ src/eths.c \ src/read_proc.c \ src/naming_policy.c \ src/sysfs.c \ src/dmidecode/dmidecode.c \ src/dmidecode/dmioem.c \ src/dmidecode/util.c src_biosdevname_LDADD = -lz -lpci EXTRA_DIST += \ src/bios_dev_name.h \ src/bios_device.h \ src/pirq.h \ src/pci.h \ src/eths.h \ src/ethtool-util.h \ src/ethtool-copy.h \ src/list.h \ src/naming_policy.h \ src/state.h \ src/sysfs.h \ src/libbiosdevname.h \ src/dmidecode/config.h \ src/dmidecode/dmidecode.h \ src/dmidecode/dmioem.h \ src/dmidecode/types.h \ src/dmidecode/util.h 07070100000017000081A40000000000000000000000015F5270920000110D000000000000000000000000000000000000003100000000biosdevname-0.7.3.7.g495ab76/src/bios_dev_name.c/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <getopt.h> #include <unistd.h> #include <sys/types.h> #include "libbiosdevname.h" #include "bios_dev_name.h" static struct bios_dev_name_opts opts; int nopirq; int smver_mjr; int smver_mnr; int is_valid_smbios = 0; static void usage(void) { fprintf(stderr, "Usage: biosdevname [options] [args]...\n"); fprintf(stderr, " Options:\n"); fprintf(stderr, " -i or --interface treat [args] as ethernet devs\n"); fprintf(stderr, " -d or --debug enable debugging\n"); fprintf(stderr, " -p or --policy [physical | all_ethN ]\n"); fprintf(stderr, " -P or --prefix [string] string use for embedded NICs (default='em')\n"); fprintf(stderr, " -s or --smbios [x.y] Require SMBIOS x.y or greater\n"); fprintf(stderr, " -x or --nopirq Don't use $PIR table for slot numbers\n"); fprintf(stderr, " -v or --version Show biosdevname version\n"); fprintf(stderr, " Example: biosdevname -i eth0\n"); fprintf(stderr, " returns: em1\n"); fprintf(stderr, " when eth0 is an embedded NIC with label '1' on the chassis.\n"); fprintf(stderr, " You must be root to run this, as it must read from /dev/mem.\n"); } static int set_policy(const char *arg) { int rc = physical; if (!strncmp("physical", arg, sizeof("physical"))) rc = physical; else if (!strncmp("all_ethN", arg, sizeof("all_ethN"))) rc = all_ethN; return rc; } static void parse_opts(int argc, char **argv) { int c; int option_index = 0; while (1) { static struct option long_options[] = /* name, has_arg, flag, val */ { {"debug", no_argument, 0, 'd'}, {"interface", no_argument, 0, 'i'}, {"policy", required_argument, 0, 'p'}, {"prefix", required_argument, 0, 'P'}, {"nopirq", no_argument, 0, 'x'}, {"smbios", required_argument, 0, 's'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "dip:P:xs:v", long_options, &option_index); if (c == -1) break; switch(c) { case 'd': opts.debug = 1; break; case 'i': opts.interface = 1; break; case 'p': opts.namingpolicy = set_policy(optarg); break; case 'P': opts.prefix = optarg; break; case 's': sscanf(optarg, "%u.%u", &smver_mjr, &smver_mnr); break; case 'x': nopirq = 1; break; case 'v': fprintf(stderr, "biosdevname version %s\n", BIOSDEVNAME_VERSION); exit(0); default: usage(); exit(1); } } if (optind < argc) { opts.argc = argc-optind; opts.argv = &argv[optind]; opts.optind = optind; } if (opts.prefix == NULL) opts.prefix = "em"; } static u_int32_t cpuid (u_int32_t eax, u_int32_t ecx) { asm volatile ( "xor %%ebx, %%ebx; cpuid" : "=a" (eax), "=c" (ecx) : "a" (eax) : "%ebx", "%edx"); return ecx; } /* Algorithm suggested by: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 */ static int running_in_virtual_machine (void) { u_int32_t eax=1U, ecx=0U; ecx = cpuid (eax, ecx); if (ecx & 0x80000000U) return 1; return 0; } static int running_as_root(void) { uid_t uid = geteuid(); if (uid != 0) { fprintf(stderr, "This program must be run as root.\n"); return 0; } return 1; } int main(int argc, char *argv[]) { int i, rc=0; char *name; void *cookie = NULL; parse_opts(argc, argv); if (!running_as_root()) exit(3); if (running_in_virtual_machine()) exit(4); cookie = setup_bios_devices(opts.namingpolicy, opts.prefix); if (!cookie) { rc = 1; goto out; } if (opts.debug) { unparse_bios_devices(cookie); rc = 0; goto out_cleanup; } if (!opts.interface) { fprintf(stderr, "Unknown device type, try passing an option like -i\n"); rc = 1; goto out_usage; } for (i=0; i<opts.argc; i++) { name = kern_to_bios(cookie, opts.argv[i]); if (name) { printf("%s\n", name); } else rc |= 2; /* one or more given devices weren't found */ } goto out_cleanup; out_usage: usage(); out_cleanup: cleanup_bios_devices(cookie); out: return rc; } 07070100000018000081A40000000000000000000000015F527092000001C2000000000000000000000000000000000000003400000000biosdevname-0.7.3.7.g495ab76/src/bios_dev_name.h.in/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #ifndef GLUE_H_INCLUDED #define GLUE_H_INCLUDED #define BIOSDEVNAME_VERSION "@PACKAGE_VERSION@" struct bios_dev_name_opts { int argc; char **argv; int optind; int sortroutine; int namingpolicy; const char *prefix; unsigned int debug:1; unsigned int interface:1; }; #endif /* GLUE_H_INCLUDED */ 07070100000019000081A40000000000000000000000015F52709200002469000000000000000000000000000000000000002F00000000biosdevname-0.7.3.7.g495ab76/src/bios_device.c/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #include <stdlib.h> #include <string.h> #include <stdio.h> #include <pci/pci.h> #include <net/if.h> #include "list.h" #include "bios_device.h" #include "state.h" #include "libbiosdevname.h" void free_bios_devices(void *cookie) { struct libbiosdevname_state *state = cookie; struct bios_device *dev, *n; if (!state) return; list_for_each_entry_safe(dev, n, &state->bios_devices, node) { list_del(&(dev->node)); free(dev->bios_name); free(dev); } } static void unparse_bios_device(struct bios_device *dev) { char buf[8192]; memset(buf, 0, sizeof(buf)); printf("BIOS device: %s\n", dev->bios_name ? dev->bios_name : ""); if (dev->netdev) { unparse_network_device(buf, sizeof(buf), dev->netdev); printf("%s", buf); } else printf(" No driver loaded for this device.\n"); if (is_pci(dev)) { unparse_pci_device(buf, sizeof(buf), dev->pcidev); printf("%s", buf); } printf("\n"); if (dev->duplicate) printf("Duplicate: True\n"); } void unparse_bios_devices(void *cookie) { struct libbiosdevname_state *state = cookie; struct bios_device *dev; if (!state) return; list_for_each_entry(dev, &state->bios_devices, node) { unparse_bios_device(dev); } } void unparse_bios_device_by_name(void *cookie, const char *name) { struct libbiosdevname_state *state = cookie; struct bios_device *dev; if (!state) return; list_for_each_entry(dev, &state->bios_devices, node) { if (dev->netdev && !strcmp(dev->netdev->kernel_name, name)) unparse_bios_device(dev); } } char * kern_to_bios(void *cookie, const char *name) { struct libbiosdevname_state *state = cookie; struct bios_device *dev; if (!state) return NULL; list_for_each_entry(dev, &state->bios_devices, node) { if (dev->netdev && !strcmp(dev->netdev->kernel_name, name)) { if (dev->duplicate) return NULL; return dev->bios_name; } } return NULL; } void unparse_bios_device_list(void *cookie) { struct libbiosdevname_state *state = cookie; struct bios_device *dev; if (!state) return; list_for_each_entry(dev, &state->bios_devices, node) { unparse_bios_device(dev); } } /* * This sorts all the embedded devices first; by PCI bus/dev/fn, then * all the add-in devices by slot number, by pci bus/dev/fn. * Unknown location devices show up as physical slot INT_MAX, so they * come last. */ static int sort_pci(const struct bios_device *bdev_a, const struct bios_device *bdev_b) { const struct pci_device *a = bdev_a->pcidev; const struct pci_device *b = bdev_b->pcidev; if (a->physical_slot < b->physical_slot) return -1; else if (a->physical_slot > b->physical_slot) return 1; if (a->pci_dev->domain < b->pci_dev->domain) return -1; else if (a->pci_dev->domain > b->pci_dev->domain) return 1; if (a->pci_dev->bus < b->pci_dev->bus) return -1; else if (a->pci_dev->bus > b->pci_dev->bus) return 1; if (a->pci_dev->dev < b->pci_dev->dev) return -1; else if (a->pci_dev->dev > b->pci_dev->dev) return 1; if (a->pci_dev->func < b->pci_dev->func) return -1; else if (a->pci_dev->func > b->pci_dev->func) return 1; return 0; } static int sort_smbios(const struct bios_device *x, const struct bios_device *y) { struct pci_device *a, *b; if (x->pcidev && !y->pcidev) return -1; else if (!x->pcidev && y->pcidev) return 1; else if (!x->pcidev && !y->pcidev) return 0; a = x->pcidev; b = y->pcidev; if (a->physical_slot == 0 && b->physical_slot == 0) { if ( a->smbios_type == b->smbios_type) { if ( a->smbios_instance < b->smbios_instance) return -1; else if (a->smbios_instance > b->smbios_instance) return 1; } } else { if (a->physical_slot < b->physical_slot) return -1; else if (a->physical_slot > b->physical_slot) return 1; } /* Check if PCI devices are same, sort by ifindex */ if (a == b) { if (x->netdev->ifindex < y->netdev->ifindex) return -1; if (x->netdev->ifindex > y->netdev->ifindex) return 1; } return sort_pci(x, y); } enum bios_device_types { IS_PCI, IS_UNKNOWN_TYPE, }; static int bios_device_type_num(const struct bios_device *dev) { if (is_pci(dev)) return IS_PCI; return IS_UNKNOWN_TYPE; } static int sort_by_type(const struct bios_device *a, const struct bios_device *b) { if (bios_device_type_num(a) < bios_device_type_num(b)) return -1; else if (bios_device_type_num(a) == bios_device_type_num(b)) { if (is_pci(a)) return sort_smbios(a, b); else return 0; } else if (bios_device_type_num(a) > bios_device_type_num(b)) return 1; return 0; } static void insertion_sort_devices(struct bios_device *a, struct list_head *list, int (*cmp)(const struct bios_device *, const struct bios_device *)) { struct bios_device *b; list_for_each_entry(b, list, node) { if (cmp(a, b) <= 0) { list_move_tail(&a->node, &b->node); return; } } list_move_tail(&a->node, list); } static void sort_device_list(struct libbiosdevname_state *state) { LIST_HEAD(sorted_devices); struct bios_device *dev, *tmp; list_for_each_entry_safe(dev, tmp, &state->bios_devices, node) { insertion_sort_devices(dev, &sorted_devices, sort_by_type); } list_splice(&sorted_devices, &state->bios_devices); } /* Check for multiport drivers */ int ismultiport(const char *driver) { if (!strncmp(driver, "mlx4", 4)) return 1; if (!strncmp(driver, "cxgb", 4)) return 1; if (!strncmp(driver, "exanic", 6)) return 1; if (!strncmp(driver, "nfp", 3)) return 1; return 0; } static void match_pci_and_eth_devs(struct libbiosdevname_state *state) { struct pci_device *p; struct bios_device *b; struct network_device *n; char pci_name[40]; list_for_each_entry(p, &state->pci_devices, node) { if (!is_pci_network(p)) continue; /* Loop through all ether devices to find match */ unparse_pci_name(pci_name, sizeof(pci_name), p->pci_dev); list_for_each_entry(n, &state->network_devices, node) { //Accept only Ethernet devices, otherwise ignore. if(!netdev_arphrd_type_is_eth(n)) continue; if (strncmp(n->drvinfo.bus_info, pci_name, sizeof(n->drvinfo.bus_info))) continue; /* Ignore if devtype is fcoe */ if (netdev_devtype_is_fcoe(n)) continue; if (!netdev_is_eligible(n)) continue; b = malloc(sizeof(*b)); if (!b) continue; memset(b, 0, sizeof(*b)); INIT_LIST_HEAD(&b->node); b->pcidev = p; b->netdev = n; b->port = NULL; if (ismultiport(n->drvinfo.driver)) { b->port = malloc(sizeof(struct pci_port)); if (b->port != NULL) { b->port->port = n->devid+1; b->port->pfi = p->is_sriov_virtual_function ? p->vf_index : -1; } } claim_netdev(b->netdev); list_add(&b->node, &state->bios_devices); } } } static void match_unknown_eths(struct libbiosdevname_state *state) { struct bios_device *b; struct network_device *n; list_for_each_entry(n, &state->network_devices, node) { if (netdev_is_claimed(n)) continue; if (!drvinfo_valid(n)) continue; if (!is_ethernet(n)) /* for virtual interfaces */ continue; /* Ignore if devtype is fcoe */ if (netdev_devtype_is_fcoe(n)) continue; b = malloc(sizeof(*b)); if (!b) continue; memset(b, 0, sizeof(*b)); INIT_LIST_HEAD(&b->node); b->netdev = n; b->port = NULL; list_add(&b->node, &state->bios_devices); } } static void match_all(struct libbiosdevname_state *state) { match_pci_and_eth_devs(state); match_unknown_eths(state); } static struct libbiosdevname_state * alloc_state(void) { struct libbiosdevname_state *state; state = malloc(sizeof(*state)); if (!state) return NULL; INIT_LIST_HEAD(&state->bios_devices); INIT_LIST_HEAD(&state->pci_devices); INIT_LIST_HEAD(&state->network_devices); INIT_LIST_HEAD(&state->slots); state->pacc = NULL; state->pirq_table = NULL; return state; } void cleanup_bios_devices(void *cookie) { struct libbiosdevname_state *state = cookie; if (!state) return; free_bios_devices(state); free_eths(state); free_pci_devices(state); if (state->pacc) pci_cleanup(state->pacc); if (state->pirq_table) pirq_free_table(state->pirq_table); } static int duplicates(struct bios_device *a, struct bios_device *b) { int lenA = -1, lenB = -1, rc = -1; if (a->bios_name) lenA = strlen(a->bios_name); if (b->bios_name) lenB = strlen(b->bios_name); if (lenA == lenB && lenA > 0) rc = strncmp(a->bios_name, b->bios_name, lenA); return !rc; } static void find_duplicates(struct libbiosdevname_state *state) { struct bios_device *a = NULL, *b = NULL; list_for_each_entry(a, &state->bios_devices, node) { list_for_each_entry(b, &state->bios_devices, node) { if (a == b) continue; if (duplicates(a, b)) { a->duplicate = 1; b->duplicate = 1; } } } } void * setup_bios_devices(int namingpolicy, const char *prefix) { int rc=1; struct libbiosdevname_state *state = alloc_state(); if (!state) return NULL; rc = get_pci_devices(state); if (rc) goto out; get_eths(state); match_all(state); sort_device_list(state); rc = assign_bios_network_names(state, namingpolicy, prefix); if (rc) goto out; find_duplicates(state); return state; out: cleanup_bios_devices(state); free(state); return NULL; } 0707010000001A000081A40000000000000000000000015F5270920000026D000000000000000000000000000000000000002F00000000biosdevname-0.7.3.7.g495ab76/src/bios_device.h/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #ifndef BIOS_DEVICE_H_INCLUDED #define BIOS_DEVICE_H_INCLUDED #include <pci/pci.h> #include "list.h" #include "eths.h" #include "pci.h" #include "naming_policy.h" struct pci_port; struct bios_device { struct list_head node; struct network_device *netdev; struct pci_device *pcidev; char *bios_name; struct pci_port *port; int duplicate; }; static inline int is_pci(const struct bios_device *dev) { return dev->pcidev != NULL; } #endif /* BIOS_DEVICE_H_INCLUDED */ 0707010000001B000041ED0000000000000000000000025F52709200000000000000000000000000000000000000000000002B00000000biosdevname-0.7.3.7.g495ab76/src/dmidecode0707010000001C000081A40000000000000000000000015F52709200000469000000000000000000000000000000000000003300000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/AUTHORSDEVELOPER AND MAINTAINER Jean Delvare <khali@linux-fr.org> ORIGINAL AUTHOR Alan Cox <alan@redhat.com> CODE CONTRIBUTORS (IN CHRONOLOGICAL ORDER) Matt Domsch <Matt_Domsch@dell.com> Arjan van de Ven <arjanv@redhat.com> Mark D. Studebaker <mds@paradyne.com> Larry Lile <llile@dreamworks.com> Dave Johnson <ddj@cascv.brown.edu> Petter Reinholdtsen <pere@hungry.com> Roberto Nibali <ratz@tac.ch> John Cagle <jcagle@kernel.org> Jens Elkner <elkner@linofee.org> MANY THANKS TO (IN CHRONOLOGICAL ORDER) Werner Heuser Alexandre Duret-Lutz Xavier Roche Pamela Huntley Gael Stephan Sebastian Henschel Richard Sharpe David Wilson Glen Foster Chad Smith Joshua Goldenhar Luc Van de Velde Mario Lang Hugues Lepesant Sergey Leonovich Mike Cooper Marc Rieffel Jeff Moyer Josef Moellers Zing Zing Shishak Rafael Avila de Espindola Roger Koot Martin Pool Doug Brenner Alex Williamson Durval Menezes Raphael Raimbault Raul Nunez de Arenas Coronado Francois Revol Dominik Klein Erwan Velu Don Howard Frans Pop Tomek Mateja Myke Olson Torsten Seemann Garry Belka Klaus Muth Antoine Fuselier Matthew Garrett Landry Breuil Luke Suchocki Attila Nagy 0707010000001D000081A40000000000000000000000015F52709200000142000000000000000000000000000000000000003500000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/CHANGELOG2007-07-19 Matt Domsch <Matt_Domsch@dell.com> * remove most of the code, leaving only what's needed by bios_dev_name. 2007-06-30 Jean Delvare <khali@linux-fr.org> * config.h: Add support for Solaris (x86 only, of course). Based on a patch by Sun's Dan Mick, brought to my knowledge by Attila Nagy. 0707010000001E000081A40000000000000000000000015F5270920000092A000000000000000000000000000000000000003400000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/Makefile# # DMI Decode # BIOS Decode # # (C) 2000-2002 Alan Cox <alan@redhat.com> # (C) 2002-2007 Jean Delvare <khali@linux-fr.org> # # Licensed under the GNU Public License. # CC = gcc CFLAGS = -W -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wmissing-prototypes -Winline -Wundef #CFLAGS += -DBIGENDIAN #CFLAGS += -DALIGNMENT_WORKAROUND # When debugging, disable -O2 and enable -g. #CFLAGS += -O2 CFLAGS += -g # Pass linker flags here LDFLAGS = DESTDIR = prefix = /usr/local sbindir = $(prefix)/sbin mandir = $(prefix)/share/man man8dir = $(mandir)/man8 docdir = $(prefix)/share/doc/dmidecode INSTALL := install INSTALL_DATA := $(INSTALL) -m 644 INSTALL_DIR := $(INSTALL) -m 755 -d INSTALL_PROGRAM := $(INSTALL) -m 755 RM := rm -f PROGRAMS := dmidecode # BSD make doesn't understand the $(shell) syntax above, it wants the != # syntax below. GNU make ignores the line below so in the end both BSD # make and GNU make are happy. all : $(PROGRAMS) # # Programs # dmidecode : dmidecode.o dmioem.o util.o $(CC) $(LDFLAGS) dmidecode.o dmioem.o util.o -o $@ # # Objects # dmidecode.o : dmidecode.c types.h util.h config.h dmidecode.h dmioem.h $(CC) $(CFLAGS) -c $< -o $@ dmioem.o : dmioem.c types.h dmidecode.h dmioem.h $(CC) $(CFLAGS) -c $< -o $@ util.o : util.c types.h util.h config.h $(CC) $(CFLAGS) -c $< -o $@ # # Commands # strip : $(PROGRAMS) strip $(PROGRAMS) install : install-bin install-man install-doc uninstall : uninstall-bin uninstall-man uninstall-doc install-bin : $(PROGRAMS) $(INSTALL_DIR) $(DESTDIR)$(sbindir) for program in $(PROGRAMS) ; do \ $(INSTALL_PROGRAM) $$program $(DESTDIR)$(sbindir) ; done uninstall-bin : for program in $(PROGRAMS) ; do \ $(RM) $(DESTDIR)$(sbindir)/$$program ; done install-man : $(INSTALL_DIR) $(DESTDIR)$(man8dir) for program in $(PROGRAMS) ; do \ $(INSTALL_DATA) man/$$program.8 $(DESTDIR)$(man8dir) ; done uninstall-man : for program in $(PROGRAMS) ; do \ $(RM) $(DESTDIR)$(man8dir)/$$program.8 ; done install-doc : $(INSTALL_DIR) $(DESTDIR)$(docdir) $(INSTALL_DATA) README $(DESTDIR)$(docdir) $(INSTALL_DATA) CHANGELOG $(DESTDIR)$(docdir) $(INSTALL_DATA) AUTHORS $(DESTDIR)$(docdir) uninstall-doc : $(RM) -r $(DESTDIR)$(docdir) clean : $(RM) *.o $(PROGRAMS) core 0707010000001F000081A40000000000000000000000015F527092000001AD000000000000000000000000000000000000003400000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/config.h/* * Configuration */ #ifndef CONFIG_H #define CONFIG_H /* Default memory device file */ #ifdef __BEOS__ #define DEFAULT_MEM_DEV "/dev/misc/mem" #else #ifdef __sun #define DEFAULT_MEM_DEV "/dev/xsvc" #else #define DEFAULT_MEM_DEV "/dev/mem" #endif #endif /* Use mmap or not */ #ifndef __BEOS__ #define USE_MMAP #endif /* Use memory alignment workaround or not */ #ifdef __ia64__ #define ALIGNMENT_WORKAROUND #endif #endif 07070100000020000081A40000000000000000000000015F52709200002ECA000000000000000000000000000000000000003700000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/dmidecode.c/* * Trimmed from DMI Decode http://savannah.nongnu.org/projects/dmidecode * * (C) 2000-2002 Alan Cox <alan@redhat.com> * (C) 2002-2007 Jean Delvare <khali@linux-fr.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For the avoidance of doubt the "preferred form" of this code is one which * is in an open unpatent encumbered format. Where cryptographic key signing * forms part of the process of creating an executable the information * including keys needed to generate an equivalently functional executable * are deemed to be part of the source code. */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include "config.h" #include "types.h" #include "util.h" #include "dmidecode.h" #include "dmioem.h" #include "../state.h" #include "../pci.h" #include "../naming_policy.h" extern int smver_mjr, smver_mnr, is_valid_smbios; #ifdef DEBUG #define dprintf printf #else #define dprintf(a...) #endif static const char *bad_index = "<BAD INDEX>"; /* * Type-independant Stuff */ const char *dmi_string(struct dmi_header *dm, u8 s) { char *bp=(char *)dm->data; size_t i, len; if(s==0) return "Not Specified"; bp+=dm->length; while(s>1 && *bp) { bp+=strlen(bp); bp++; s--; } if(!*bp) return bad_index; /* ASCII filtering */ len=strlen(bp); for(i=0; i<len; i++) if(bp[i]<32 || bp[i]==127) bp[i]='.'; return bp; } /* * Main */ #define MIN(a,b) (((a)<(b))?(a):(b)) static void strip_right(char *s) { int i, len = strlen(s); for (i=len; i>=0; i--) { if (isspace(s[i-1])) s[i-1] = '\0'; else break; } } static int matchpci(struct pci_device *pdev, int domain, int bus, int device, int func) { if (domain != -1 && pdev->pci_dev->domain != domain) return 0; if (bus != -1 && pdev->pci_dev->bus != bus) return 0; if (device != -1 && pdev->pci_dev->dev != device) return 0; if (func != -1 && pdev->pci_dev->func != func) return 0; return 1; } void smbios_setslot(const struct libbiosdevname_state *state, int domain, int bus, int device, int func, int type, int slot, int index, const char *label) { struct pci_device *pdev; dprintf("setslot: %.4x:%.2x:%.2x.%x = type:%x slot(%2d %2d) %s\n", domain, bus, device, func, type, slot, index, label); /* Don't bother with disabled devices */ if ((domain == 0xFFFF) || (bus == 0 && device == 0 && func == 0) || /* bug on HP systems */ (bus == 0xFF && device == 0x1F && func == 0x7)) { dprintf(" disabled\n"); return; } list_for_each_entry(pdev, &state->pci_devices, node) { if (!matchpci(pdev, domain, bus, device, func)) continue; dprintf(" found device: %.4x:%.2x:%.2x.%x = %lx\n", pdev->pci_dev->domain, pdev->pci_dev->bus, pdev->pci_dev->dev, pdev->pci_dev->func, pdev->class); pdev->uses_smbios |= HAS_SMBIOS_SLOT; if (index != 0) pdev->uses_smbios |= HAS_SMBIOS_INSTANCE; pdev->smbios_type = type; pdev->smbios_enabled = 1; pdev->smbios_instance = index; pdev->physical_slot = slot; if (label) { pdev->smbios_label = strdup(label); pdev->uses_smbios |= HAS_SMBIOS_LABEL; strip_right(pdev->smbios_label); } /* Found a PDEV, now is it a bridge? */ if (pdev->sbus != -1 && pdev->sbus > bus) { smbios_setslot(state, domain, pdev->sbus, -1, -1, type, slot, index, label); } } } static void dmi_decode(struct dmi_header *h, u16 ver, const struct libbiosdevname_state *state) { u8 *data=h->data; int domain, bus, device, function; switch(h->type) { case 9: /* 3.3.10 System Slots */ if (h->length >= 0x0E && h->length >=0x11) { domain = WORD(data+0x0D); bus = data[0x0F]; device = (data[0x10]>>3)&0x1F; function = data[0x10] & 7; /* Root ports can be on multiport device.. scan single */ if (!is_root_port(state, domain, bus, device, function)) function = -1; smbios_setslot(state, domain, bus, device, function, 0x00, WORD(data+0x09), 0x00, dmi_string(h, data[0x04])); } else { dprintf("Old Slot: id:%3d, type:%.2x, label:%-7s\n", WORD(data+0x09), data[0x05], dmi_string(h, data[0x04])); } break; case 41: /* 3.3.xx Onboard Device Information */ domain = WORD(data+0x07); bus = data[0x09]; device = (data[0xa]>>3) & 0x1F; function = data[0xa] & 0x7; if (data[5] == (0x80 | 0x05)) { // enabled and type == ethernet smbios_setslot(state, domain, bus, device, function, data[5] & 0x7F, 0x00, data[0x06], dmi_string(h, data[0x04])); } break; default: if(dmi_decode_oem(h, state)) break; } } static void to_dmi_header(struct dmi_header *h, u8 *data) { h->type=data[0]; h->length=data[1]; h->handle=WORD(data+2); h->data=data; } static int isvalidsmbios(int mjr, int mnr) { if (!smver_mjr && !smver_mnr) { is_valid_smbios = 1; return 1; } if (mjr > smver_mjr) { is_valid_smbios = 1; return 1; } if ((mjr == smver_mjr) && (mnr >= smver_mnr)) { is_valid_smbios = 1; return 1; } return 0; } static int dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, const struct libbiosdevname_state *state, int sysfs) { u8 *buf; u8 *data; int i=0; /* Verify SMBIOS version */ if (ver && !isvalidsmbios(ver >> 8, ver & 0xFF)) { return 0; } if (sysfs) buf = __mem_chunk(0, len, devmem, 0); else buf = mem_chunk(base, len, devmem); if(buf == NULL) { #ifndef USE_MMAP printf("Table is unreachable, sorry. Try compiling dmidecode with -DUSE_MMAP.\n"); #endif return 0; } data=buf; while((!num || i<num) && data+4<=buf+len) /* 4 is the length of an SMBIOS structure header */ { u8 *next; struct dmi_header h; to_dmi_header(&h, data); /* * If a short entry is found (less than 4 bytes), not only it * is invalid, but we cannot reliably locate the next entry. * Better stop at this point, and let the user know his/her * table is broken. */ if(h.length<4) break; /* assign vendor for vendor-specific decodes later */ if(h.type==0 && h.length>=5) dmi_set_vendor(dmi_string(&h, data[0x04])); /* look for the next handle */ next=data+h.length; while(next-buf+1<len && (next[0]!=0 || next[1]!=0)) next++; next+=2; if(next-buf<=len) dmi_decode(&h, ver, state); data=next; i++; } free(buf); return 1; } static int smbios_decode(u8 *buf, const char *devmem, const struct libbiosdevname_state *state, int sysfs) { if(checksum(buf, buf[0x05]) && memcmp(buf+0x10, "_DMI_", 5)==0 && checksum(buf+0x10, 0x0F)) { return dmi_table(DWORD(buf+0x18), WORD(buf+0x16), WORD(buf+0x1C), (buf[0x06]<<8)+buf[0x07], devmem, state, sysfs); } return 0; } static int legacy_decode(u8 *buf, const char *devmem, const struct libbiosdevname_state *state) { if(checksum(buf, 0x0F)) { dmi_table(DWORD(buf+0x08), WORD(buf+0x06), WORD(buf+0x0C), ((buf[0x0E]&0xF0)<<4)+(buf[0x0E]&0x0F), devmem, state, 0); return 1; } return 0; } /* only from sysfs, handle no base offset */ static int smbios3_decode(u8 *buf, const char *devmem, const struct libbiosdevname_state *state) { if (checksum(buf, 0x18)) return dmi_table(0, DWORD(buf + 0x0c), 0, 0, devmem, state, 1); return 0; } #define SYSFS_TABLE_SMBIOS "/sys/firmware/dmi/tables/smbios_entry_point" #define SYSFS_TABLE_DMI "/sys/firmware/dmi/tables/DMI" static int smibios_decode_from_sysfs(const struct libbiosdevname_state *state) { FILE *fp; u8 buf[0x1f]; int len; fp = fopen(SYSFS_TABLE_SMBIOS, "r"); if (!fp) return 0; len = fread(buf, 1, sizeof(buf), fp); fclose(fp); if (len == 0x1f && memcmp(buf, "_SM_", 4) == 0) return smbios_decode(buf, SYSFS_TABLE_DMI, state, 1); if (len >= 0x18 && memcmp(buf, "_SM3_", 5) == 0) return smbios3_decode(buf, SYSFS_TABLE_DMI, state); return 0; } /* * Probe for EFI interface */ #define EFI_NOT_FOUND (-1) #define EFI_NO_SMBIOS (-2) static int address_from_efi(size_t *address) { FILE *efi_systab; const char *filename; char linebuf[64]; int ret; *address=0; /* Prevent compiler warning */ /* * Linux up to 2.6.6: /proc/efi/systab * Linux 2.6.7 and up: /sys/firmware/efi/systab */ if((efi_systab=fopen(filename="/sys/firmware/efi/systab", "r"))==NULL && (efi_systab=fopen(filename="/proc/efi/systab", "r"))==NULL) { /* No EFI interface, fallback to memory scan */ return EFI_NOT_FOUND; } ret=EFI_NO_SMBIOS; while((fgets(linebuf, sizeof(linebuf)-1, efi_systab))!=NULL) { char *addrp=strchr(linebuf, '='); *(addrp++)='\0'; if(strcmp(linebuf, "SMBIOS")==0) { *address=strtoul(addrp, NULL, 0); ret=0; break; } } if(fclose(efi_systab)!=0) perror(filename); if(ret==EFI_NO_SMBIOS) fprintf(stderr, "%s: SMBIOS entry point missing\n", filename); return ret; } static const char *devmem = "/dev/mem"; int dmidecode_read_file(const struct libbiosdevname_state *state) { #ifdef _JPH FILE *fp; const char *dmidecode_file = "dmidecode.txt"; char line[128], *r; int type = -1, eth=0,s,b,d,f,slot,i; if ((fp = fopen(dmidecode_file, "r")) == NULL) return 0; while ((fgets(line, sizeof(line), fp)) != NULL) { if (strstr(line, " DMI type 41,") != NULL) { type = 41; eth = 0; slot = -1; } else if (strstr(line, " DMI type 9,") != NULL) { type = 9; } else if (strstr(line, " DMI type ") != NULL) { type = -1; } if (type == 41) { if ((r = strstr(line, "Type: Ethernet")) != NULL) { eth = 1; } if ((r = strstr(line, "Type Instance: ")) != NULL) { sscanf(r, "Type Instance: %d", &slot); } if ((r = strstr(line, "Bus Address: ")) != NULL && eth) { sscanf(r, "Bus Address: %x:%x:%x.%x", &s,&b,&d,&f); printf("bus: %.4x:%.2x:%.2x.%x\n", s, b, d, f); smbios_setslot(state, s, b, d, f, 0x5, 0x00, slot, ""); } } if (type == 9) { /* System Slots */ if ((r = strstr(line, "ID: ")) != NULL) { sscanf(r, "ID: %d", &slot); } if ((r = strstr(line, "Bus Address: ")) != NULL) { sscanf(r, "Bus Address: %x:%x:%x.%x", &s,&b,&d,&f); printf("bus: %.4x:%.2x:%.2x.%x = %d\n", s, b, d, f, slot); for (i=0; i<8; i++) smbios_setslot(state, s, b, d, i, 0x00, slot, 0x00, ""); } } } return 1; #endif return 0; } int dmidecode_main(const struct libbiosdevname_state *state) { int ret=0; /* Returned value */ int found=0; size_t fp; int efi; u8 *buf; if (dmidecode_read_file(state)) return 0; /* First try sysfs entries */ if (smibios_decode_from_sysfs(state)) return 0; /* Next try EFI (ia64, Intel-based Mac) */ efi=address_from_efi(&fp); switch(efi) { case EFI_NOT_FOUND: goto memory_scan; case EFI_NO_SMBIOS: ret=1; goto exit_free; } if((buf=mem_chunk(fp, 0x20, devmem))==NULL) { ret=1; goto exit_free; } if(smbios_decode(buf, devmem, state, 0)) found++; goto done; memory_scan: /* Fallback to memory scan (x86, x86_64) */ if((buf=mem_chunk(0xF0000, 0x10000, devmem))==NULL) { ret=1; goto exit_free; } for(fp=0; fp<=0xFFF0; fp+=16) { if(memcmp(buf+fp, "_SM_", 4)==0 && fp<=0xFFE0) { if(smbios_decode(buf+fp, devmem, state, 0)) { found++; fp+=16; } } else if(memcmp(buf+fp, "_DMI_", 5)==0) { if (legacy_decode(buf+fp, devmem, state)) found++; } } done: free(buf); exit_free: return ret; } 07070100000021000081A40000000000000000000000015F52709200000689000000000000000000000000000000000000003700000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/dmidecode.h/* * This file is part of the dmidecode project. * * (C) 2005-2007 Jean Delvare <khali@linux-fr.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ struct dmi_header { u8 type; u8 length; u16 handle; u8 *data; }; const char *dmi_string(struct dmi_header *dm, u8 s); struct dmi_embedded_device { u8 type; u8 instance; u16 domain; u8 bus; u8 device; u8 function; const char *reference_designation; }; struct dmi_addon_device { u8 type; u8 instance; u16 domain; u8 bus; u8 device; u8 function; const char *reference_designation; }; enum dmi_onboard_device_type { DMI_OTHER=1, DMI_UNKNOWN, DMI_VIDEO, DMI_SCSI, DMI_ETHERNET, DMI_TOKEN_RING, DMI_SOUND, DMI_PATA, DMI_SATA, DMI_SAS, }; struct libbiosdevname_state; int dmidecode_main(const struct libbiosdevname_state *state); void smbios_setslot(const struct libbiosdevname_state *state, int domain, int bus, int device, int func, int type, int slot, int index, const char *label); 07070100000022000081A40000000000000000000000015F5270920000099F000000000000000000000000000000000000003400000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/dmioem.c/* * Decoding of OEM-specific entries * This file is part of the dmidecode project. * * (C) 2007 Jean Delvare <khali@linux-fr.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdio.h> #include <string.h> #include "types.h" #include "dmidecode.h" #include "dmioem.h" #include "../pci.h" /* * Globals for vendor-specific decodes */ enum DMI_VENDORS { VENDOR_UNKNOWN, VENDOR_HP }; static enum DMI_VENDORS dmi_vendor=VENDOR_UNKNOWN; /* * Remember the system vendor for later use. We only actually store the * value if we know how to decode at least one specific entry type for * that vendor. */ void dmi_set_vendor(const char *s) { if(strcmp(s, "HP")==0) dmi_vendor=VENDOR_HP; } /* * HP-specific data structures are decoded here. * * Code contributed by John Cagle. */ static int dmi_decode_hp(struct dmi_header *h, const struct libbiosdevname_state *state) { u8 *data=h->data; int nic, ptr; u8 smbios_type = 0; u8 bus, device, func; switch(h->type) { case 209: /* * Vendor Specific: HP ProLiant NIC MAC Information * * This prints the BIOS NIC number, * PCI bus/device/function, and MAC address */ smbios_type=0x05; nic=1; ptr=4; while(h->length>=ptr+8) { bus = data[ptr+1]; device = data[ptr]>>3; func = data[ptr]&7; smbios_setslot(state, 0, bus, device, func, smbios_type, 0, nic, NULL); nic++; ptr += 8; } break; default: return 0; } return 1; } /* * Dispatch vendor-specific entries decoding * Return 1 if decoding was successful, 0 otherwise */ int dmi_decode_oem(struct dmi_header *h, const struct libbiosdevname_state *state) { switch(dmi_vendor) { case VENDOR_HP: return dmi_decode_hp(h, state); default: return 0; } } 07070100000023000081A40000000000000000000000015F52709200000411000000000000000000000000000000000000003400000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/dmioem.h/* * Decoding of OEM-specific entries * This file is part of the dmidecode project. * * (C) 2007 Jean Delvare <khali@linux-fr.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../state.h" struct dmi_header; void dmi_set_vendor(const char *s); int dmi_decode_oem(struct dmi_header *h, const struct libbiosdevname_state *state); 07070100000024000081A40000000000000000000000015F527092000002FF000000000000000000000000000000000000003300000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/types.h#ifndef TYPES_H #define TYPES_H #include "config.h" typedef unsigned char u8; typedef unsigned short u16; typedef signed short i16; typedef unsigned int u32; #ifdef ALIGNMENT_WORKAROUND # ifdef BIGENDIAN # define WORD(x) (u16)((x)[1]+((x)[0]<<8)) # define DWORD(x) (u32)((x)[3]+((x)[2]<<8)+((x)[1]<<16)+((x)[0]<<24)) # define QWORD(x) (U64(DWORD(x+4), DWORD(x))) # else /* BIGENDIAN */ # define WORD(x) (u16)((x)[0]+((x)[1]<<8)) # define DWORD(x) (u32)((x)[0]+((x)[1]<<8)+((x)[2]<<16)+((x)[3]<<24)) # define QWORD(x) (U64(DWORD(x), DWORD(x+4))) # endif /* BIGENDIAN */ #else /* ALIGNMENT_WORKAROUND */ #define WORD(x) (u16)(*(const u16 *)(x)) #define DWORD(x) (u32)(*(const u32 *)(x)) #define QWORD(x) (*(const u64 *)(x)) #endif /* ALIGNMENT_WORKAROUND */ #endif 07070100000025000081A40000000000000000000000015F52709200000F23000000000000000000000000000000000000003200000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/util.c/* * Common "util" functions * This file is part of the dmidecode project. * * (C) 2002-2005 Jean Delvare <khali@linux-fr> * * 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 * * For the avoidance of doubt the "preferred form" of this code is one which * is in an open unpatent encumbered format. Where cryptographic key signing * forms part of the process of creating an executable the information * including keys needed to generate an equivalently functional executable * are deemed to be part of the source code. */ #include <sys/types.h> #include <sys/stat.h> #include "config.h" #ifdef USE_MMAP #include <sys/mman.h> #ifndef MAP_FAILED #define MAP_FAILED ((void *) -1) #endif /* !MAP_FAILED */ #endif /* USE MMAP */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <errno.h> #include "types.h" #include "util.h" static int myread(int fd, u8 *buf, size_t count, const char *prefix) { ssize_t r=1; size_t r2=0; while(r2!=count && r!=0) { r=read(fd, buf+r2, count-r2); if(r==-1) { if(errno!=EINTR) { close(fd); perror(prefix); return -1; } } else r2+=r; } if(r2!=count) { close(fd); fprintf(stderr, "%s: Unexpected end of file\n", prefix); return -1; } return 0; } int checksum(const u8 *buf, size_t len) { u8 sum=0; size_t a; for(a=0; a<len; a++) sum+=buf[a]; return (sum==0); } /* * Copy a physical memory chunk into a memory buffer. * This function allocates memory. */ #ifdef USE_MMAP static void *mem_chunk_mmap(size_t base, size_t len, const char *devmem, int fd, void *p) { size_t mmoffset; void *mmp; #ifdef _SC_PAGESIZE mmoffset=base%sysconf(_SC_PAGESIZE); #else mmoffset=base%getpagesize(); #endif /* _SC_PAGESIZE */ /* * Please note that we don't use mmap() for performance reasons here, * but to workaround problems many people encountered when trying * to read from /dev/mem using regular read() calls. */ mmp=mmap(0, mmoffset+len, PROT_READ, MAP_SHARED, fd, base-mmoffset); if(mmp==MAP_FAILED) { return NULL; } memcpy(p, (u8 *)mmp+mmoffset, len); if(munmap(mmp, mmoffset+len)==-1) { fprintf(stderr, "%s: ", devmem); perror("munmap"); } return p; } #endif /* USE_MMAP */ static void *mem_chunk_read(size_t base, size_t len, const char *devmem, int fd, void *p) { if(lseek(fd, base, SEEK_SET)==-1) { fprintf(stderr, "%s: ", devmem); perror("lseek"); return NULL; } if(myread(fd, p, len, devmem)==-1) { return NULL; } return p; } void *__mem_chunk(size_t base, size_t len, const char *devmem, int use_mmap) { void *ret; void *p; int fd; #ifndef USE_MMAP use_mmap = 0; #endif if((fd=open(devmem, O_RDONLY))==-1) { return NULL; } if((p=malloc(len))==NULL) { perror("malloc"); close(fd); return NULL; } #ifdef USE_MMAP if (use_mmap) ret = mem_chunk_mmap(base, len, devmem, fd, p); else #endif ret = mem_chunk_read(base, len, devmem, fd, p); if(close(fd)==-1) perror(devmem); if (!ret) free(p); return ret; } void *mem_chunk(size_t base, size_t len, const char *devmem) { return __mem_chunk(base, len, devmem, 1); } 07070100000026000081A40000000000000000000000015F52709200000113000000000000000000000000000000000000003200000000biosdevname-0.7.3.7.g495ab76/src/dmidecode/util.h#include <sys/types.h> #include "types.h" #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) int checksum(const u8 *buf, size_t len); void *mem_chunk(size_t base, size_t len, const char *devmem); void *__mem_chunk(size_t base, size_t len, const char *devmem, int use_mmap); 07070100000027000081A40000000000000000000000015F52709200002345000000000000000000000000000000000000002800000000biosdevname-0.7.3.7.g495ab76/src/eths.c/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #define _GNU_SOURCE #include <string.h> #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <sys/types.h> #include <getopt.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <linux/sockios.h> #include <unistd.h> #include <net/if.h> #include <net/if_arp.h> #include "ethtool-util.h" #include "pci.h" #include "eths.h" #include "state.h" #include "sysfs.h" /* Display an Ethernet address in readable format. */ char *pr_ether(char *buf, const int size, const unsigned char *s) { snprintf(buf, size, "%02X:%02X:%02X:%02X:%02X:%02X", (s[0] & 0377), (s[1] & 0377), (s[2] & 0377), (s[3] & 0377), (s[4] & 0377), (s[5] & 0377) ); return (buf); } static int eths_get_phys_port_name_id(const char *devname) { char *portstr = NULL; char path[PATH_MAX]; int index = -1; /* Only devices that have a phys_port_name of 'pX' are considered here, * with the index 'X' extracted. */ snprintf(path, sizeof(path), "/sys/class/net/%s/phys_port_name", devname); if (sysfs_read_file(path, &portstr) == 0) { char *res = NULL; if (portstr[0] == 'p') { index = strtol(&portstr[1], &res, 10); /* Reset to invalid if the format is unexpected. */ if (*res) index = -1; } free(portstr); } return index; } static void eths_get_dev_eligible(struct network_device *dev) { /* By default, all network devices are eligible for naming. Some may * opt-out explicitly below. */ dev->is_eligible = 1; if (dev->drvinfo_valid && strcmp(dev->drvinfo.driver, "nfp") == 0) { dev->is_eligible = (eths_get_phys_port_name_id(dev->kernel_name) >= 0 ? 1 : 0); } } static void eths_get_devid(struct network_device *dev) { char path[PATH_MAX]; char *devidstr = NULL; dev->devid = -1; /* For some drivers, the phys_port_name index, e.g. pX, is the correct * dev ID to use instead of the dev_port attribute. */ if (dev->drvinfo_valid && strcmp(dev->drvinfo.driver, "nfp") == 0) { dev->devid = eths_get_phys_port_name_id(dev->kernel_name); } else { snprintf(path, sizeof(path), "/sys/class/net/%s/dev_port", dev->kernel_name); if (sysfs_read_file(path, &devidstr) == 0) { sscanf(devidstr, "%i", &dev->devid); free(devidstr); } else { snprintf(path, sizeof(path), "/sys/class/net/%s/dev_id", dev->kernel_name); if (sysfs_read_file(path, &devidstr) == 0) { sscanf(devidstr, "%i", &dev->devid); free(devidstr); } } } } static int eths_get_devtype(struct network_device *dev) { int fd; int ret = 0; ssize_t length = 0; char path[PATH_MAX]; char *result = NULL, *n, *temp; unsigned long resultsize = 0, devtype_len = 0; snprintf(path, sizeof(path), "/sys/class/net/%s/uevent", dev->kernel_name); resultsize = getpagesize(); result = malloc(resultsize); if (!result) return -ENOMEM; memset(result, 0, resultsize); fd = open(path, O_RDONLY); if (fd < 0) { ret = fd; goto free_out; } length = read(fd, result, resultsize-1); close(fd); if (length < 0) { ret = -1; goto free_out; } result[length] = '\0'; n = strstr(result, "DEVTYPE="); if (n) { n += strlen("DEVTYPE="); if (!strncmp(n, "fcoe", 4)) ret = 1; } if (ret && (temp = strstr(n, "\n")) != NULL) { *temp = '\0'; devtype_len = strlen(n); dev->devtype = malloc(devtype_len + 1); if (dev->devtype) { memset(dev->devtype, 0, devtype_len + 1); strncpy(dev->devtype, n, devtype_len); } } free_out: free(result); return ret; } static int eths_get_ifindex(const char *devname, int *ifindex) { int fd, err; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name)-1); /* Open control socket. */ fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { perror("Cannot get control socket"); return 1; } err = ioctl(fd, SIOCGIFINDEX, &ifr); if (!err) { *ifindex = ifr.ifr_ifindex; } close(fd); return err; } static int eths_get_hwaddr(const char *devname, unsigned char *buf, int size, int *type) { int fd, err; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name)-1); /* Open control socket. */ fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { perror("Cannot get control socket"); return 1; } err = ioctl(fd, SIOCGIFHWADDR, &ifr); if (!err) { memcpy(buf, ifr.ifr_hwaddr.sa_data, min(size, sizeof(ifr.ifr_hwaddr.sa_data))); *type = ifr.ifr_hwaddr.sa_family; } close(fd); return err; } static int eths_get_info(const char *devname, struct ethtool_drvinfo *drvinfo) { int fd, err; struct ifreq ifr; /* Setup our control structures. */ memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name)-1); /* Open control socket. */ fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { perror("Cannot get control socket"); return 1; } drvinfo->cmd = ETHTOOL_GDRVINFO; ifr.ifr_data = (caddr_t)drvinfo; err = ioctl(fd, SIOCETHTOOL, &ifr); close(fd); return err; } static int eths_get_permaddr(const char *devname, unsigned char *buf, int size) { int fd, err; struct ifreq ifr; struct ethtool_perm_addr *permaddr; int s = sizeof(*permaddr) + MAX_ADDR_LEN; permaddr = malloc(s); if (!permaddr) return 1; memset(permaddr, 0, s); /* Setup our control structures. */ memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name)-1); /* Open control socket. */ fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { free(permaddr); perror("Cannot get control socket"); return 1; } permaddr->cmd = ETHTOOL_GPERMADDR; permaddr->size = MAX_ADDR_LEN; ifr.ifr_data = (caddr_t)permaddr; err = ioctl(fd, SIOCETHTOOL, &ifr); if (err < 0) { close(fd); free(permaddr); return err; } memcpy(buf, permaddr->data, min(permaddr->size, size)); free(permaddr); close(fd); return err; } static void fill_eth_dev(struct network_device *dev) { int rc, devtype; eths_get_ifindex(dev->kernel_name, &dev->ifindex); eths_get_hwaddr(dev->kernel_name, dev->dev_addr, sizeof(dev->dev_addr), &dev->arphrd_type); eths_get_permaddr(dev->kernel_name, dev->perm_addr, sizeof(dev->perm_addr)); devtype = eths_get_devtype(dev); if (devtype > 0) dev->devtype_is_fcoe = 1; rc = eths_get_info(dev->kernel_name, &dev->drvinfo); if (rc == 0) dev->drvinfo_valid = 1; eths_get_devid(dev); eths_get_dev_eligible(dev); } void free_eths(struct libbiosdevname_state *state) { struct network_device *pos, *next; list_for_each_entry_safe(pos, next, &state->network_devices, node) { list_del(&pos->node); free(pos); } } /* read_proc.c */ extern int get_interfaces(struct libbiosdevname_state *state); void get_eths(struct libbiosdevname_state *state) { struct network_device *pos; get_interfaces(state); list_for_each_entry(pos, &state->network_devices, node) { fill_eth_dev(pos); } } int zero_mac(const void *addr) { char zero_mac[MAX_ADDR_LEN]; memset(zero_mac, 0, sizeof(zero_mac)); return !memcmp(zero_mac, addr, sizeof(zero_mac)); } int unparse_network_device(char *buf, const int size, struct network_device *dev) { char buffer[40]; char *s = buf; s += snprintf(s, size-(s-buf), "Kernel name: %s\n", dev->kernel_name); if (!zero_mac(dev->perm_addr)) s += snprintf(s, size-(s-buf), "Permanent MAC: %s\n", pr_ether(buffer, sizeof(buffer), dev->perm_addr)); s += snprintf(s, size-(s-buf), "Assigned MAC : %s\n", pr_ether(buffer, sizeof(buffer), dev->dev_addr)); s += snprintf(s, size-(s-buf), "ifIndex: %d\n", dev->ifindex); if (drvinfo_valid(dev)) { s += snprintf(s, size-(s-buf), "Driver: %s\n", dev->drvinfo.driver); s += snprintf(s, size-(s-buf), "Driver version: %s\n", dev->drvinfo.version); s += snprintf(s, size-(s-buf), "Firmware version: %s\n", dev->drvinfo.fw_version); s += snprintf(s, size-(s-buf), "Bus Info: %s\n", dev->drvinfo.bus_info); } return (s-buf); }; struct network_device * find_net_device_by_bus_info(struct libbiosdevname_state *state, const char *bus_info) { struct network_device *n; list_for_each_entry(n, &state->network_devices, node) { if (!strncmp(n->drvinfo.bus_info, bus_info, sizeof(n->drvinfo.bus_info))) return n; } return NULL; } int is_ethernet(struct network_device *dev) { int i; int rc = 0; /* FIXME: /sys/class/net/$kernel_name/device will be a symlink if there's underlying hardware, * or not exist if it's virtual. Try using that if this isn't good enough already. */ /* No bus means not visible to BIOS */ if (strncmp("N/A", dev->drvinfo.bus_info, sizeof(dev->drvinfo.bus_info)) == 0) goto out; const char *nonethernet_drivers[] = { "bonding", "bridge", "openvswitch", "tun", }; for (i=0; i<sizeof(nonethernet_drivers)/sizeof(nonethernet_drivers[0]); i++) { if (strncmp(dev->drvinfo.driver, nonethernet_drivers[i], sizeof(dev->drvinfo.driver)) == 0) goto out; } rc = dev->arphrd_type == ARPHRD_ETHER; out: return rc; } 07070100000028000081A40000000000000000000000015F52709200000818000000000000000000000000000000000000002800000000biosdevname-0.7.3.7.g495ab76/src/eths.h/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #ifndef __ETHS_H_INCLUDED #define __ETHS_H_INCLUDED #include <net/if.h> #include <net/if_arp.h> /* Bogus */ #undef MAX_ADDR_LEN #define MAX_ADDR_LEN 32 #include "list.h" #include "ethtool-util.h" #include "state.h" struct network_device { struct list_head node; char kernel_name[IFNAMSIZ]; /* ethN */ unsigned char perm_addr[MAX_ADDR_LEN]; unsigned char dev_addr[MAX_ADDR_LEN]; /* mutable MAC address, not unparsed */ struct ethtool_drvinfo drvinfo; int drvinfo_valid; int arphrd_type; /* e.g. ARPHDR_ETHER */ int hardware_claimed; /* true when recognized as PCI or PCMCIA and added to list of bios_devices */ int ifindex; int devid; int devtype_is_fcoe; char *devtype; int is_eligible:1; /* not eligible for naming when 0 */ }; extern void get_eths(struct libbiosdevname_state *state); extern void free_eths(struct libbiosdevname_state *state); extern int unparse_network_device(char *buf, const int size, struct network_device *dev); extern struct network_device * find_net_device_by_bus_info(struct libbiosdevname_state *state, const char *bus_info); extern int is_ethernet(struct network_device *dev); extern int zero_mac(const void *addr); #define min(a,b) ((a) <= (b) ? (a) : (b)) static inline void claim_netdev(struct network_device *dev) { dev->hardware_claimed = 1; } static inline int netdev_is_claimed(const struct network_device *dev) { return dev->hardware_claimed != 0; } static inline int drvinfo_valid(const struct network_device *dev) { return dev->drvinfo_valid != 0; } static inline int netdev_devtype_is_fcoe(const struct network_device *dev) { return (dev->devtype_is_fcoe == 1); } static inline int netdev_arphrd_type_is_eth(const struct network_device *dev) { return (dev->arphrd_type == ARPHRD_ETHER); } static inline int netdev_is_eligible(const struct network_device *dev) { return (!!dev->is_eligible); } #endif /* __ETHS_H_INCLUDED */ 07070100000029000081A40000000000000000000000015F52709200002FAD000000000000000000000000000000000000003000000000biosdevname-0.7.3.7.g495ab76/src/ethtool-copy.h/* * ethtool.h: Defines for Linux ethtool. * * Copyright (C) 1998 David S. Miller (davem@redhat.com) * Copyright 2001 Jeff Garzik <jgarzik@mandrakesoft.com> * Portions Copyright 2001 Sun Microsystems (thockin@sun.com) * Portions Copyright 2002 Intel (eli.kupermann@intel.com, * christopher.leech@intel.com, * scott.feldman@intel.com) */ #ifndef _LINUX_ETHTOOL_H #define _LINUX_ETHTOOL_H /* This should work for both 32 and 64 bit userland. */ struct ethtool_cmd { u32 cmd; u32 supported; /* Features this interface supports */ u32 advertising; /* Features this interface advertises */ u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */ u8 duplex; /* Duplex, half or full */ u8 port; /* Which connector port */ u8 phy_address; u8 transceiver; /* Which tranceiver to use */ u8 autoneg; /* Enable or disable autonegotiation */ u32 maxtxpkt; /* Tx pkts before generating tx int */ u32 maxrxpkt; /* Rx pkts before generating rx int */ u32 reserved[4]; }; #define ETHTOOL_BUSINFO_LEN 32 /* these strings are set to whatever the driver author decides... */ struct ethtool_drvinfo { u32 cmd; char driver[32]; /* driver short name, "tulip", "eepro100" */ char version[32]; /* driver version string */ char fw_version[32]; /* firmware version string, if applicable */ char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */ /* For PCI devices, use pci_dev->slot_name. */ char reserved1[32]; char reserved2[16]; u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */ u32 testinfo_len; u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */ u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */ }; #define SOPASS_MAX 6 /* wake-on-lan settings */ struct ethtool_wolinfo { u32 cmd; u32 supported; u32 wolopts; u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */ }; /* for passing single values */ struct ethtool_value { u32 cmd; u32 data; }; /* for passing big chunks of data */ struct ethtool_regs { u32 cmd; u32 version; /* driver-specific, indicates different chips/revs */ u32 len; /* bytes */ u8 data[0]; }; /* for passing EEPROM chunks */ struct ethtool_eeprom { u32 cmd; u32 magic; u32 offset; /* in bytes */ u32 len; /* in bytes */ u8 data[0]; }; /* for configuring coalescing parameters of chip */ struct ethtool_coalesce { u32 cmd; /* ETHTOOL_{G,S}COALESCE */ /* How many usecs to delay an RX interrupt after * a packet arrives. If 0, only rx_max_coalesced_frames * is used. */ u32 rx_coalesce_usecs; /* How many packets to delay an RX interrupt after * a packet arrives. If 0, only rx_coalesce_usecs is * used. It is illegal to set both usecs and max frames * to zero as this would cause RX interrupts to never be * generated. */ u32 rx_max_coalesced_frames; /* Same as above two parameters, except that these values * apply while an IRQ is being services by the host. Not * all cards support this feature and the values are ignored * in that case. */ u32 rx_coalesce_usecs_irq; u32 rx_max_coalesced_frames_irq; /* How many usecs to delay a TX interrupt after * a packet is sent. If 0, only tx_max_coalesced_frames * is used. */ u32 tx_coalesce_usecs; /* How many packets to delay a TX interrupt after * a packet is sent. If 0, only tx_coalesce_usecs is * used. It is illegal to set both usecs and max frames * to zero as this would cause TX interrupts to never be * generated. */ u32 tx_max_coalesced_frames; /* Same as above two parameters, except that these values * apply while an IRQ is being services by the host. Not * all cards support this feature and the values are ignored * in that case. */ u32 tx_coalesce_usecs_irq; u32 tx_max_coalesced_frames_irq; /* How many usecs to delay in-memory statistics * block updates. Some drivers do not have an in-memory * statistic block, and in such cases this value is ignored. * This value must not be zero. */ u32 stats_block_coalesce_usecs; /* Adaptive RX/TX coalescing is an algorithm implemented by * some drivers to improve latency under low packet rates and * improve throughput under high packet rates. Some drivers * only implement one of RX or TX adaptive coalescing. Anything * not implemented by the driver causes these values to be * silently ignored. */ u32 use_adaptive_rx_coalesce; u32 use_adaptive_tx_coalesce; /* When the packet rate (measured in packets per second) * is below pkt_rate_low, the {rx,tx}_*_low parameters are * used. */ u32 pkt_rate_low; u32 rx_coalesce_usecs_low; u32 rx_max_coalesced_frames_low; u32 tx_coalesce_usecs_low; u32 tx_max_coalesced_frames_low; /* When the packet rate is below pkt_rate_high but above * pkt_rate_low (both measured in packets per second) the * normal {rx,tx}_* coalescing parameters are used. */ /* When the packet rate is (measured in packets per second) * is above pkt_rate_high, the {rx,tx}_*_high parameters are * used. */ u32 pkt_rate_high; u32 rx_coalesce_usecs_high; u32 rx_max_coalesced_frames_high; u32 tx_coalesce_usecs_high; u32 tx_max_coalesced_frames_high; /* How often to do adaptive coalescing packet rate sampling, * measured in seconds. Must not be zero. */ u32 rate_sample_interval; }; /* for configuring RX/TX ring parameters */ struct ethtool_ringparam { u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */ /* Read only attributes. These indicate the maximum number * of pending RX/TX ring entries the driver will allow the * user to set. */ u32 rx_max_pending; u32 rx_mini_max_pending; u32 rx_jumbo_max_pending; u32 tx_max_pending; /* Values changeable by the user. The valid values are * in the range 1 to the "*_max_pending" counterpart above. */ u32 rx_pending; u32 rx_mini_pending; u32 rx_jumbo_pending; u32 tx_pending; }; /* for configuring link flow control parameters */ struct ethtool_pauseparam { u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */ /* If the link is being auto-negotiated (via ethtool_cmd.autoneg * being true) the user may set 'autonet' here non-zero to have the * pause parameters be auto-negotiated too. In such a case, the * {rx,tx}_pause values below determine what capabilities are * advertised. * * If 'autoneg' is zero or the link is not being auto-negotiated, * then {rx,tx}_pause force the driver to use/not-use pause * flow control. */ u32 autoneg; u32 rx_pause; u32 tx_pause; }; #define ETH_GSTRING_LEN 32 enum ethtool_stringset { ETH_SS_TEST = 0, ETH_SS_STATS, }; /* for passing string sets for data tagging */ struct ethtool_gstrings { u32 cmd; /* ETHTOOL_GSTRINGS */ u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/ u32 len; /* number of strings in the string set */ u8 data[0]; }; enum ethtool_test_flags { ETH_TEST_FL_OFFLINE = (1 << 0), /* online / offline */ ETH_TEST_FL_FAILED = (1 << 1), /* test passed / failed */ }; /* for requesting NIC test and getting results*/ struct ethtool_test { u32 cmd; /* ETHTOOL_TEST */ u32 flags; /* ETH_TEST_FL_xxx */ u32 reserved; u32 len; /* result length, in number of u64 elements */ u64 data[0]; }; /* for dumping NIC-specific statistics */ struct ethtool_stats { u32 cmd; /* ETHTOOL_GSTATS */ u32 n_stats; /* number of u64's being returned */ u64 data[0]; }; struct ethtool_perm_addr { u32 cmd; /* ETHTOOL_GPERMADDR */ u32 size; u8 data[0]; }; /* CMDs currently supported */ #define ETHTOOL_GSET 0x00000001 /* Get settings. */ #define ETHTOOL_SSET 0x00000002 /* Set settings, privileged. */ #define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */ #define ETHTOOL_GREGS 0x00000004 /* Get NIC registers, privileged. */ #define ETHTOOL_GWOL 0x00000005 /* Get wake-on-lan options. */ #define ETHTOOL_SWOL 0x00000006 /* Set wake-on-lan options, priv. */ #define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */ #define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level, priv. */ #define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation, priv. */ #define ETHTOOL_GLINK 0x0000000a /* Get link status (ethtool_value) */ #define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */ #define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data, priv. */ #define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */ #define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config, priv. */ #define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters */ #define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters, priv. */ #define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */ #define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters, priv. */ #define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */ #define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */ #define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */ #define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */ #define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable * (ethtool_value) */ #define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable * (ethtool_value), priv. */ #define ETHTOOL_TEST 0x0000001a /* execute NIC self-test, priv. */ #define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */ #define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */ #define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */ #define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */ #define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */ #define ETHTOOL_GPERMADDR 0x00000020 /* Get permanent hardware address */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET #define SPARC_ETH_SSET ETHTOOL_SSET /* Indicates what features are supported by the interface. */ #define SUPPORTED_10baseT_Half (1 << 0) #define SUPPORTED_10baseT_Full (1 << 1) #define SUPPORTED_100baseT_Half (1 << 2) #define SUPPORTED_100baseT_Full (1 << 3) #define SUPPORTED_1000baseT_Half (1 << 4) #define SUPPORTED_1000baseT_Full (1 << 5) #define SUPPORTED_Autoneg (1 << 6) #define SUPPORTED_TP (1 << 7) #define SUPPORTED_AUI (1 << 8) #define SUPPORTED_MII (1 << 9) #define SUPPORTED_FIBRE (1 << 10) #define SUPPORTED_BNC (1 << 11) #define SUPPORTED_10000baseT_Full (1 << 12) /* Indicates what features are advertised by the interface. */ #define ADVERTISED_10baseT_Half (1 << 0) #define ADVERTISED_10baseT_Full (1 << 1) #define ADVERTISED_100baseT_Half (1 << 2) #define ADVERTISED_100baseT_Full (1 << 3) #define ADVERTISED_1000baseT_Half (1 << 4) #define ADVERTISED_1000baseT_Full (1 << 5) #define ADVERTISED_Autoneg (1 << 6) #define ADVERTISED_TP (1 << 7) #define ADVERTISED_AUI (1 << 8) #define ADVERTISED_MII (1 << 9) #define ADVERTISED_FIBRE (1 << 10) #define ADVERTISED_BNC (1 << 11) #define ADVERTISED_10000baseT_Full (1 << 12) /* The following are all involved in forcing a particular link * mode for the device for setting things. When getting the * devices settings, these indicate the current mode and whether * it was foced up into this mode or autonegotiated. */ /* The forced speed, 10Mb, 100Mb, gigabit, 10GbE. */ #define SPEED_10 10 #define SPEED_100 100 #define SPEED_1000 1000 #define SPEED_10000 10000 /* Duplex, half or full. */ #define DUPLEX_HALF 0x00 #define DUPLEX_FULL 0x01 /* Which connector port. */ #define PORT_TP 0x00 #define PORT_AUI 0x01 #define PORT_MII 0x02 #define PORT_FIBRE 0x03 #define PORT_BNC 0x04 /* Which tranceiver to use. */ #define XCVR_INTERNAL 0x00 #define XCVR_EXTERNAL 0x01 #define XCVR_DUMMY1 0x02 #define XCVR_DUMMY2 0x03 #define XCVR_DUMMY3 0x04 /* Enable or disable autonegotiation. If this is set to enable, * the forced link modes above are completely ignored. */ #define AUTONEG_DISABLE 0x00 #define AUTONEG_ENABLE 0x01 /* Wake-On-Lan options. */ #define WAKE_PHY (1 << 0) #define WAKE_UCAST (1 << 1) #define WAKE_MCAST (1 << 2) #define WAKE_BCAST (1 << 3) #define WAKE_ARP (1 << 4) #define WAKE_MAGIC (1 << 5) #define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */ #endif /* _LINUX_ETHTOOL_H */ 0707010000002A000081A40000000000000000000000015F527092000001C1000000000000000000000000000000000000003000000000biosdevname-0.7.3.7.g495ab76/src/ethtool-util.h/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #ifndef ETHTOOL_UTIL_H__ #define ETHTOOL_UTIL_H__ #include <pci/pci.h> #include <limits.h> #if ULONG_MAX > 0xffffffff typedef unsigned long u64; #else typedef unsigned long long u64; #endif #include "ethtool-copy.h" int ethtool_get_info(const char *devname, struct ethtool_drvinfo *drvinfo); #endif 0707010000002B000081A40000000000000000000000015F5270920000025E000000000000000000000000000000000000003200000000biosdevname-0.7.3.7.g495ab76/src/libbiosdevname.h/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #ifndef LIBBIOSDEVNAME_H_INCLUDED #define LIBBIOSDEVNAME_H_INCLUDED enum namingpolicy { physical, all_ethN, }; extern void * setup_bios_devices(int namingpolicy, const char *prefix); extern void cleanup_bios_devices(void *cookie); extern char * kern_to_bios(void *cookie, const char *devname); extern void unparse_bios_devices(void *cookie); extern void unparse_bios_device_by_name(void *cookie, const char *name); #endif /* LIBBIOSDEVNAME_H_INCLUDED */ 0707010000002C000081A40000000000000000000000015F527092000031AE000000000000000000000000000000000000002800000000biosdevname-0.7.3.7.g495ab76/src/list.h/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. * Copied from the Linux kernel version 2.6.18, modfied for use here. */ #ifndef _LINUX_LIST_H #define _LINUX_LIST_H #include <stddef.h> /** * container_of - cast a member of a structure out to the containing structure * @ptr: the pointer to the member. * @type: the type of the container struct this is embedded in. * @member: the name of the member within the struct. * */ #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) /* * Simple doubly linked list implementation, from Linux kernel 2.6.18 * * Some of the internal functions ("__xxx") are useful when * manipulating whole lists rather than single entries, as * sometimes we already know the next/prev entries and we can * generate better code by using them directly rather than * using the generic single-entry routines. */ struct list_head { struct list_head *next, *prev; }; #define LIST_HEAD_INIT(name) { &(name), &(name) } #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) static inline void INIT_LIST_HEAD(struct list_head *list) { list->next = list; list->prev = list; } /* * Insert a new entry between two known consecutive entries. * * This is only for internal list manipulation where we know * the prev/next entries already! */ static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { next->prev = new; new->next = next; new->prev = prev; prev->next = new; } /** * list_add - add a new entry * @new: new entry to be added * @head: list head to add it after * * Insert a new entry after the specified head. * This is good for implementing stacks. */ static inline void list_add(struct list_head *new, struct list_head *head) { __list_add(new, head, head->next); } /** * list_add_tail - add a new entry * @new: new entry to be added * @head: list head to add it before * * Insert a new entry before the specified head. * This is useful for implementing queues. */ static inline void list_add_tail(struct list_head *new, struct list_head *head) { __list_add(new, head->prev, head); } /* * Delete a list entry by making the prev/next entries * point to each other. * * This is only for internal list manipulation where we know * the prev/next entries already! */ static inline void __list_del(struct list_head * prev, struct list_head * next) { next->prev = prev; prev->next = next; } /** * list_del - deletes entry from list. * @entry: the element to delete from the list. * Note: list_empty on entry does not return true after this, the entry is * in an undefined state. */ static inline void list_del(struct list_head *entry) { __list_del(entry->prev, entry->next); entry->next = NULL; entry->prev = NULL; } /** * list_replace - replace old entry by new one * @old : the element to be replaced * @new : the new element to insert * Note: if 'old' was empty, it will be overwritten. */ static inline void list_replace(struct list_head *old, struct list_head *new) { new->next = old->next; new->next->prev = new; new->prev = old->prev; new->prev->next = new; } static inline void list_replace_init(struct list_head *old, struct list_head *new) { list_replace(old, new); INIT_LIST_HEAD(old); } /** * list_del_init - deletes entry from list and reinitialize it. * @entry: the element to delete from the list. */ static inline void list_del_init(struct list_head *entry) { __list_del(entry->prev, entry->next); INIT_LIST_HEAD(entry); } /** * list_move - delete from one list and add as another's head * @list: the entry to move * @head: the head that will precede our entry */ static inline void list_move(struct list_head *list, struct list_head *head) { __list_del(list->prev, list->next); list_add(list, head); } /** * list_move_tail - delete from one list and add as another's tail * @list: the entry to move * @head: the head that will follow our entry */ static inline void list_move_tail(struct list_head *list, struct list_head *head) { __list_del(list->prev, list->next); list_add_tail(list, head); } /** * list_is_last - tests whether @list is the last entry in list @head * @list: the entry to test * @head: the head of the list */ static inline int list_is_last(const struct list_head *list, const struct list_head *head) { return list->next == head; } /** * list_empty - tests whether a list is empty * @head: the list to test. */ static inline int list_empty(const struct list_head *head) { return head->next == head; } /** * list_empty_careful - tests whether a list is empty and not being modified * @head: the list to test * * Description: * tests whether a list is empty _and_ checks that no other CPU might be * in the process of modifying either member (next or prev) * * NOTE: using list_empty_careful() without synchronization * can only be safe if the only activity that can happen * to the list entry is list_del_init(). Eg. it cannot be used * if another CPU could re-list_add() it. */ static inline int list_empty_careful(const struct list_head *head) { struct list_head *next = head->next; return (next == head) && (next == head->prev); } static inline void __list_splice(struct list_head *list, struct list_head *head) { struct list_head *first = list->next; struct list_head *last = list->prev; struct list_head *at = head->next; first->prev = head; head->next = first; last->next = at; at->prev = last; } /** * list_splice - join two lists * @list: the new list to add. * @head: the place to add it in the first list. */ static inline void list_splice(struct list_head *list, struct list_head *head) { if (!list_empty(list)) __list_splice(list, head); } /** * list_splice_init - join two lists and reinitialise the emptied list. * @list: the new list to add. * @head: the place to add it in the first list. * * The list at @list is reinitialised */ static inline void list_splice_init(struct list_head *list, struct list_head *head) { if (!list_empty(list)) { __list_splice(list, head); INIT_LIST_HEAD(list); } } /** * list_entry - get the struct for this entry * @ptr: the &struct list_head pointer. * @type: the type of the struct this is embedded in. * @member: the name of the list_struct within the struct. */ #define list_entry(ptr, type, member) \ container_of(ptr, type, member) /** * list_for_each - iterate over a list * @pos: the &struct list_head to use as a loop cursor. * @head: the head for your list. */ #define list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); \ pos = pos->next) /** * __list_for_each - iterate over a list * @pos: the &struct list_head to use as a loop cursor. * @head: the head for your list. * * This variant differs from list_for_each() in that it's the * simplest possible list iteration code, no prefetching is done. * Use this for code that knows the list to be very short (empty * or 1 entry) most of the time. */ #define __list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) /** * list_for_each_prev - iterate over a list backwards * @pos: the &struct list_head to use as a loop cursor. * @head: the head for your list. */ #define list_for_each_prev(pos, head) \ for (pos = (head)->prev; pos != (head); \ pos = pos->prev) /** * list_for_each_safe - iterate over a list safe against removal of list entry * @pos: the &struct list_head to use as a loop cursor. * @n: another &struct list_head to use as temporary storage * @head: the head for your list. */ #define list_for_each_safe(pos, n, head) \ for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) /** * list_for_each_entry - iterate over list of given type * @pos: the type * to use as a loop cursor. * @head: the head for your list. * @member: the name of the list_struct within the struct. */ #define list_for_each_entry(pos, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member); \ &pos->member != (head); \ pos = list_entry(pos->member.next, typeof(*pos), member)) /** * list_for_each_entry_reverse - iterate backwards over list of given type. * @pos: the type * to use as a loop cursor. * @head: the head for your list. * @member: the name of the list_struct within the struct. */ #define list_for_each_entry_reverse(pos, head, member) \ for (pos = list_entry((head)->prev, typeof(*pos), member); \ &pos->member != (head); \ pos = list_entry(pos->member.prev, typeof(*pos), member)) /** * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue * @pos: the type * to use as a start point * @head: the head of the list * @member: the name of the list_struct within the struct. * * Prepares a pos entry for use as a start point in list_for_each_entry_continue. */ #define list_prepare_entry(pos, head, member) \ ((pos) ? : list_entry(head, typeof(*pos), member)) /** * list_for_each_entry_continue - continue iteration over list of given type * @pos: the type * to use as a loop cursor. * @head: the head for your list. * @member: the name of the list_struct within the struct. * * Continue to iterate over list of given type, continuing after * the current position. */ #define list_for_each_entry_continue(pos, head, member) \ for (pos = list_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ pos = list_entry(pos->member.next, typeof(*pos), member)) /** * list_for_each_entry_from - iterate over list of given type from the current point * @pos: the type * to use as a loop cursor. * @head: the head for your list. * @member: the name of the list_struct within the struct. * * Iterate over list of given type, continuing from current position. */ #define list_for_each_entry_from(pos, head, member) \ for (; &pos->member != (head); \ pos = list_entry(pos->member.next, typeof(*pos), member)) /** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @pos: the type * to use as a loop cursor. * @n: another type * to use as temporary storage * @head: the head for your list. * @member: the name of the list_struct within the struct. */ #define list_for_each_entry_safe(pos, n, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member), \ n = list_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) /** * list_for_each_entry_safe_continue * @pos: the type * to use as a loop cursor. * @n: another type * to use as temporary storage * @head: the head for your list. * @member: the name of the list_struct within the struct. * * Iterate over list of given type, continuing after current point, * safe against removal of list entry. */ #define list_for_each_entry_safe_continue(pos, n, head, member) \ for (pos = list_entry(pos->member.next, typeof(*pos), member), \ n = list_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) /** * list_for_each_entry_safe_from * @pos: the type * to use as a loop cursor. * @n: another type * to use as temporary storage * @head: the head for your list. * @member: the name of the list_struct within the struct. * * Iterate over list of given type from current point, safe against * removal of list entry. */ #define list_for_each_entry_safe_from(pos, n, head, member) \ for (n = list_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) /** * list_for_each_entry_safe_reverse * @pos: the type * to use as a loop cursor. * @n: another type * to use as temporary storage * @head: the head for your list. * @member: the name of the list_struct within the struct. * * Iterate backwards over list of given type, safe against removal * of list entry. */ #define list_for_each_entry_safe_reverse(pos, n, head, member) \ for (pos = list_entry((head)->prev, typeof(*pos), member), \ n = list_entry(pos->member.prev, typeof(*pos), member); \ &pos->member != (head); \ pos = n, n = list_entry(n->member.prev, typeof(*n), member)) #endif /* _LINUX_LIST_H */ 0707010000002D000081A40000000000000000000000015F52709200000C66000000000000000000000000000000000000003100000000biosdevname-0.7.3.7.g495ab76/src/naming_policy.c/* * Copyright (c) 2006, 2007 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #include <string.h> #include <stdio.h> #include <limits.h> #include "bios_device.h" #include "naming_policy.h" #include "libbiosdevname.h" #include "state.h" #include "dmidecode/dmidecode.h" static void use_all_ethN(const struct libbiosdevname_state *state) { struct bios_device *dev; unsigned int i=0; char buffer[IFNAMSIZ]; memset(buffer, 0, sizeof(buffer)); list_for_each_entry(dev, &state->bios_devices, node) { if (dev->netdev) { snprintf(buffer, sizeof(buffer), "eth%u", i++); dev->bios_name = strdup(buffer); } } } static void use_physical(const struct libbiosdevname_state *state, const char *prefix) { struct bios_device *dev; char buffer[IFNAMSIZ]; char location[IFNAMSIZ]; char port[IFNAMSIZ]; char interface[IFNAMSIZ]; unsigned int portnum=0; int known=0; struct pci_device *vf; list_for_each_entry(dev, &state->bios_devices, node) { known = 0; memset(buffer, 0, sizeof(buffer)); memset(location, 0, sizeof(location)); memset(port, 0, sizeof(port)); memset(interface, 0, sizeof(interface)); if (is_pci(dev)) { vf = dev->pcidev; if (dev->pcidev->physical_slot == 0) { /* embedded devices only */ portnum = INT_MAX; /* Use master VPD device if available */ if (vf->vpd_pf) vf = vf->vpd_pf; if (vf->pf) vf = vf->pf; if (dev->port) portnum = dev->port->port; else if (vf->uses_sysfs & HAS_SYSFS_INDEX) portnum = vf->sysfs_index; else if (vf->uses_smbios & HAS_SMBIOS_INSTANCE && is_pci_smbios_type_ethernet(vf)) portnum = vf->smbios_instance; else if (vf->embedded_index_valid) portnum = vf->embedded_index; if (portnum != INT_MAX) { snprintf(location, sizeof(location), "%s%u", prefix, portnum); known=1; } } else if (dev->pcidev->physical_slot < PHYSICAL_SLOT_UNKNOWN) { snprintf(location, sizeof(location), "p%u", dev->pcidev->physical_slot); if (dev->port) portnum = dev->port->port; else if (dev->pcidev->vpd_port < INT_MAX) portnum = dev->pcidev->vpd_port; else if (!dev->pcidev->is_sriov_virtual_function) portnum = dev->pcidev->index_in_slot; else portnum = dev->pcidev->pf->index_in_slot; snprintf(port, sizeof(port), "p%u", portnum); known=1; } if (dev->port && dev->port->pfi != -1) snprintf(interface, sizeof(interface), "_%u", dev->port->pfi); else if (dev->pcidev->is_sriov_virtual_function) snprintf(interface, sizeof(interface), "_%u", dev->pcidev->vf_index); else if (dev->pcidev->vpd_pfi < INT_MAX) snprintf(interface, sizeof(interface), "_%u", dev->pcidev->vpd_pfi); if (known) { snprintf(buffer, sizeof(buffer), "%s%s%s", location, port, interface); dev->bios_name = strdup(buffer); } } } } int assign_bios_network_names(const struct libbiosdevname_state *state, int policy, const char *prefix) { int rc = 0; switch (policy) { case all_ethN: use_all_ethN(state); break; case physical: default: use_physical(state, prefix); break; } return rc; } 0707010000002E000081A40000000000000000000000015F5270920000018E000000000000000000000000000000000000003100000000biosdevname-0.7.3.7.g495ab76/src/naming_policy.h/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #ifndef NAMING_POLICY_H_INCLUDED #define NAMING_POLICY_H_INCLUDED #include "state.h" extern int assign_bios_network_names(const struct libbiosdevname_state *state, int namingpolicy, const char *prefix); #endif /* NAMING_POLICY_H_INCLUDED */ 0707010000002F000081A40000000000000000000000015F52709200005855000000000000000000000000000000000000002700000000biosdevname-0.7.3.7.g495ab76/src/pci.c/* * Copyright (c) 2006-2010 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <limits.h> #include <unistd.h> #include <dirent.h> #include <pci/pci.h> #include <fcntl.h> #include "pci.h" #include "sysfs.h" #include "dmidecode/dmidecode.h" #include "pirq.h" extern int is_valid_smbios; #ifndef PCI_CB_CAPABILITY_LIST #define PCI_CB_CAPABILITY_LIST 0x14 #endif /* Borrowed from kernel vpd code */ #define PCI_VPD_LRDT 0x80 #define PCI_VPD_SRDT_END 0x78 #define PCI_VPDI_TAG 0x82 #define PCI_VPDR_TAG 0x90 #define PCI_VPD_SRDT_LEN_MASK 0x7 #define PCI_VPD_LRDT_TAG_SIZE 3 #define PCI_VPD_SRDT_TAG_SIZE 1 #define PCI_VPD_INFO_FLD_HDR_SIZE 3 struct vpd_tag { char cc[2]; u8 len; char data[1]; }; static inline u16 pci_vpd_lrdt_size(const u8 *lrdt) { return (u16)lrdt[0] + ((u16)lrdt[1] << 8L); } static inline u8 pci_vpd_srdt_size(const u8* srdt) { return (*srdt) & PCI_VPD_SRDT_LEN_MASK; } static int pci_vpd_readtag(int fd, int *len) { u8 tag, tlen[2]; if (read(fd, &tag, 1) != 1) return -1; if (tag == 0x00 || tag == 0xFF || tag == 0x7F) return -1; if (tag & PCI_VPD_LRDT) { if (read(fd, tlen, 2) != 2) return -1; *len = pci_vpd_lrdt_size(tlen); /* Check length of VPD-R */ if (*len >= 1024) return -1; return tag; } *len = pci_vpd_srdt_size(&tag); return (tag & ~0x7); } static void *pci_vpd_findtag(void *buf, int len, const char *sig) { int off, siglen; struct vpd_tag *t; off = 0; siglen = strlen(sig); while (off < len) { t = (struct vpd_tag *)((u8 *)buf + off); if (!memcmp(t->data, sig, siglen)) return t; off += (t->len + 3); } return NULL; } /* Add port identifier(s) to PCI device */ static void add_port(struct pci_device *pdev, int port, int pfi) { struct pci_port *p; list_for_each_entry(p, &pdev->ports, node) { if (p->port == port && p->pfi == pfi) return; } p = malloc(sizeof(*p)); if (p == NULL) return; memset(p, 0, sizeof(*p)); INIT_LIST_HEAD(&p->node); p->port = port; p->pfi = pfi; list_add_tail(&p->node, &pdev->ports); } static void parse_dcm(struct libbiosdevname_state *state, struct pci_device *pdev, void *vpd, int len) { int i, port, devfn, pfi, step; struct pci_device *vf; struct vpd_tag *dcm; const char *fmt; if (pdev->is_sriov_virtual_function) { return ; } fmt = "%1x%1x%2x"; step = 10; dcm = pci_vpd_findtag(vpd, len, "DCM"); if (dcm == NULL) { dcm = pci_vpd_findtag(vpd, len, "DC2"); if (dcm == NULL) return; fmt = "%1x%2x%2x"; step = 11; } for (i = 3; i < dcm->len; i += step) { if (i+step > dcm->len) { /* DCM is truncated */ return; } if (sscanf(dcm->data+i, fmt, &port, &devfn, &pfi) != 3) break; vf = find_pci_dev_by_pci_addr(state, pdev->pci_dev->domain, pdev->pci_dev->bus, devfn >> 3, devfn & 7); if (vf != NULL && !vf->is_sriov_virtual_function) { add_port(vf, port, pfi); if (vf->vpd_port == INT_MAX) { vf->vpd_port = port; vf->vpd_pfi = pfi; } } } } /* Read and parse PCI VPD section if it exists */ static int read_pci_vpd(struct libbiosdevname_state *state, struct pci_device *pdev) { char path[PATH_MAX]; char pci_name[16]; int fd, len; unsigned char *vpd; if (!is_pci_network(pdev) || pdev->is_sriov_virtual_function) return 1; unparse_pci_name(pci_name, sizeof(pci_name), pdev->pci_dev); snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/physfn/vpd", pci_name); fd = open(path, O_RDONLY|O_SYNC); if (fd < 0) { snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/vpd", pci_name); fd = open(path, O_RDONLY|O_SYNC); if (fd < 0) return 1; } if (pci_vpd_readtag(fd, &len) != PCI_VPDI_TAG) goto done; lseek(fd, len, SEEK_CUR); if (pci_vpd_readtag(fd, &len) != PCI_VPDR_TAG) goto done; vpd = alloca(len); if (read(fd, vpd, len) != len) goto done; /* Check for DELL VPD tag */ if (!pci_vpd_findtag(vpd, len, "DSV1028VPDR.VER")) goto done; parse_dcm(state, pdev, vpd, len); done: close(fd); return 0; } static void set_pci_vpd_instance(struct libbiosdevname_state *state) { struct pci_device *dev, *dev2; int fd; char sys_vendor[10] = {0}; /* Read VPD-R on Dell systems only */ if ((fd = open("/sys/devices/virtual/dmi/id/sys_vendor", O_RDONLY)) >= 0) { if (read(fd, sys_vendor, 9) != 9) { close(fd); return; } if (strncmp(sys_vendor, "Dell Inc.", 9)) { close(fd); return; } } else return; /* Read VPD information for each device */ list_for_each_entry(dev, &state->pci_devices, node) { /* RedHat bugzilla 801885, 789635, 781572 */ if (dev->pci_dev->vendor_id == 0x1969 || dev->pci_dev->vendor_id == 0x168c) continue; if (dev->vpd_port != INT_MAX) { /* Ignore already parsed devices */ continue; } if (dev->is_sriov_virtual_function) { continue; } read_pci_vpd(state, dev); } /* Now match VPD master device */ list_for_each_entry(dev, &state->pci_devices, node) { if (dev->vpd_port == INT_MAX || dev->is_sriov_virtual_function) continue; list_for_each_entry(dev2, &state->pci_devices, node) { if (dev2->pci_dev->domain == dev->pci_dev->domain && dev2->pci_dev->bus == dev->pci_dev->bus && dev2->vpd_port == dev->vpd_port) { dev2->vpd_count++; dev->vpd_pf = dev2; if (dev2->physical_slot == 0) dev->physical_slot = 0; break; } } } /* Delete all VPD devices with single function */ list_for_each_entry(dev, &state->pci_devices, node) { if (dev->vpd_count == 1) { dev->vpd_port = INT_MAX; dev->vpd_pfi = INT_MAX; dev->vpd_pf = NULL; } } close(fd); } static int pci_find_capability(struct pci_dev *p, int cap) { u16 status; u8 hdr, id; int pos, ttl = 48; status = pci_read_word(p, PCI_STATUS); if (!(status & PCI_STATUS_CAP_LIST)) return 0; hdr = pci_read_byte(p, PCI_HEADER_TYPE); switch(hdr & 0x7F) { case PCI_HEADER_TYPE_NORMAL: case PCI_HEADER_TYPE_BRIDGE: pos = PCI_CAPABILITY_LIST; break; case PCI_HEADER_TYPE_CARDBUS: pos = PCI_CB_CAPABILITY_LIST; break; default: return 0; } while (ttl--) { pos = pci_read_byte(p, pos); if (pos < 0x40) break; pos &= ~3; id = pci_read_byte(p, pos+PCI_CAP_LIST_ID); if (id == 0xFF) break; if (id == cap) return pos; pos += PCI_CAP_LIST_NEXT; } return 0; } static struct pci_device * find_parent(struct libbiosdevname_state *state, struct pci_device *dev); static int pcie_get_slot(struct libbiosdevname_state *state, struct pci_device *p) { int pos; u32 slot, flag; while (p) { /* Return PCIE physical slot number */ if ((pos = pci_find_capability(p->pci_dev, PCI_CAP_ID_EXP)) != 0) { flag = pci_read_word(p->pci_dev, pos + PCI_EXP_FLAGS); slot = (pci_read_long(p->pci_dev, pos + PCI_EXP_SLTCAP) >> 19); if ((flag & PCI_EXP_FLAGS_SLOT) && slot) return slot; } p = find_parent(state, p); } return PHYSICAL_SLOT_UNKNOWN; } static int read_pci_sysfs_path(char *buf, size_t bufsize, const struct pci_dev *pdev) { char path[PATH_MAX]; char pci_name[16]; ssize_t size; unparse_pci_name(pci_name, sizeof(pci_name), pdev); snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s", pci_name); size = readlink(path, buf, bufsize); if (size == -1) return 1; return 0; } static int parse_pci_name(const char *s, int *domain, int *bus, int *dev, int *func) { int err; const char *r; /* Allow parsing pathnames */ if ((r = strrchr(s, '/')) != NULL) s = r+1; /* The domain part was added in 2.6 kernels. Test for that first. */ err = sscanf(s, "%x:%2x:%2x.%x", domain, bus, dev, func); if (err != 4) { err = sscanf(s, "%2x:%2x.%x", bus, dev, func); if (err != 3) { return 1; } } return 0; } static struct pci_dev * find_pdev_by_pci_name(struct pci_access *pacc, const char *s) { int domain=0, bus=0, device=0, func=0; if (parse_pci_name(s, &domain, &bus, &device, &func)) return NULL; return pci_get_dev(pacc, domain, bus, device, func); } static int is_same_pci(const struct pci_dev *a, const struct pci_dev *b) { if (pci_domain_nr(a) == pci_domain_nr(b) && a->bus == b->bus && a->dev == b->dev && a->func == b->func) return 1; return 0; } static struct pci_device * find_parent(struct libbiosdevname_state *state, struct pci_device *dev) { int rc; char path[PATH_MAX]; char *c; struct pci_dev *pdev; memset(path, 0, sizeof(path)); rc = read_pci_sysfs_path(path, sizeof(path), dev->pci_dev); if (rc != 0) return NULL; /* we get back a string like ../../../devices/pci0000:00/0000:00:09.0/0000:05:17.4 where the last component is the device we asked for */ /* find the last backslash */ c = rindex(path, '/'); *c = '\0'; /* find the last backslash again */ c = rindex(path, '/'); c++; pdev = find_pdev_by_pci_name(state->pacc, c); if (pdev) { dev = find_dev_by_pci(state, pdev); return dev; } return NULL; } /* * Check our parents in case the device itself isn't listed * in the SMBIOS table. This has a problem, as * our parent bridge on a card may not be included * in the SMBIOS table. In that case, it falls back to "unknown". */ static inline int pci_dev_to_slot(struct libbiosdevname_state *state, struct pci_device *dev) { return dev->physical_slot; } static inline int pirq_dev_to_slot(struct libbiosdevname_state *state, struct pci_device *dev) { return pirq_pci_dev_to_slot(state->pirq_table, pci_domain_nr(dev->pci_dev), dev->pci_dev->bus, dev->pci_dev->dev); } static void dev_to_slot(struct libbiosdevname_state *state, struct pci_device *dev) { struct pci_device *d = dev; int slot; do { slot = pci_dev_to_slot(state, d); if (slot == PHYSICAL_SLOT_UNKNOWN && is_valid_smbios) slot = pcie_get_slot(state, d); if (slot == PHYSICAL_SLOT_UNKNOWN) slot = pirq_dev_to_slot(state, d); if (slot == PHYSICAL_SLOT_UNKNOWN) d = find_parent(state, d); } while (d && slot == PHYSICAL_SLOT_UNKNOWN); dev->physical_slot = slot; } static char *read_pci_sysfs_label(const struct pci_dev *pdev) { char path[PATH_MAX]; char pci_name[16]; int rc; char *label = NULL; unparse_pci_name(pci_name, sizeof(pci_name), pdev); snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/label", pci_name); rc = sysfs_read_file(path, &label); if (rc == 0) return label; return NULL; } static int read_pci_sysfs_index(unsigned int *index, const struct pci_dev *pdev) { char path[PATH_MAX]; char pci_name[16]; int rc; char *indexstr = NULL; unsigned int i; unparse_pci_name(pci_name, sizeof(pci_name), pdev); snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/index", pci_name); rc = sysfs_read_file(path, &indexstr); if (rc == 0) { rc = sscanf(indexstr, "%u", &i); free(indexstr); if (rc == 1) { *index = i; return 0; } } return 1; } static void fill_pci_dev_sysfs(struct pci_device *dev, struct pci_dev *p) { int rc; unsigned int index = 0; char *label = NULL; char buf[PATH_MAX]; unparse_pci_name(buf, sizeof(buf), p); rc = read_pci_sysfs_index(&index, p); if (!rc) { dev->sysfs_index = index; dev->uses_sysfs |= HAS_SYSFS_INDEX; } label = read_pci_sysfs_label(p); if (label) { dev->sysfs_label = label; dev->uses_sysfs |= HAS_SYSFS_LABEL; } } static void add_pci_dev(struct libbiosdevname_state *state, struct pci_dev *p) { struct pci_device *dev; uint8_t hdr; dev = malloc(sizeof(*dev)); if (!dev) { fprintf(stderr, "out of memory\n"); return; } memset(dev, 0, sizeof(*dev)); INIT_LIST_HEAD(&dev->node); INIT_LIST_HEAD(&dev->vfnode); INIT_LIST_HEAD(&dev->vfs); INIT_LIST_HEAD(&dev->ports); dev->pci_dev = p; dev->physical_slot = PHYSICAL_SLOT_UNKNOWN; dev->class = pci_read_word(p, PCI_CLASS_DEVICE); dev->vf_index = INT_MAX; dev->vpd_port = INT_MAX; dev->vpd_pfi = INT_MAX; dev->vpd_pf = NULL; fill_pci_dev_sysfs(dev, p); list_add(&dev->node, &state->pci_devices); /* Get subordinate bus if this is a bridge */ hdr = pci_read_byte(p, PCI_HEADER_TYPE); switch (hdr & 0x7F) { case PCI_HEADER_TYPE_BRIDGE: case PCI_HEADER_TYPE_CARDBUS: dev->sbus = pci_read_byte(p, PCI_SECONDARY_BUS); break; default: dev->sbus = -1; break; } } void free_pci_devices(struct libbiosdevname_state *state) { struct pci_device *pos, *next; list_for_each_entry_safe(pos, next, &state->pci_devices, node) { if (pos->smbios_label) free(pos->smbios_label); if (pos->sysfs_label) free(pos->sysfs_label); list_del(&pos->node); free(pos); } } static void set_pci_slots(struct libbiosdevname_state *state) { struct pci_device *dev; list_for_each_entry(dev, &state->pci_devices, node) { dev_to_slot(state, dev); } } static int set_pci_slot_index(struct libbiosdevname_state *state) { struct pci_device *pcidev; int prevslot=-1; int index=1; /* only iterate over the PCI devices, because the bios_device list may be incomplete due to renames happening in parallel */ list_for_each_entry(pcidev, &state->pci_devices, node) { if (pcidev->physical_slot == 0) /* skip embedded devices */ continue; if (!is_pci_network(pcidev)) /* only look at PCI network devices */ continue; if (pcidev->is_sriov_virtual_function) /* skip sriov VFs, they're handled later */ continue; if (pcidev->physical_slot != prevslot) { index=1; prevslot = pcidev->physical_slot; } else index++; pcidev->index_in_slot = index; } return 0; } static int set_embedded_index(struct libbiosdevname_state *state) { struct pci_device *pcidev; int index=1; list_for_each_entry(pcidev, &state->pci_devices, node) { if (pcidev->physical_slot != 0) /* skip non-embedded devices */ continue; if (!is_pci_network(pcidev)) /* only look at PCI network devices */ continue; if (pcidev->is_sriov_virtual_function) /* skip sriov VFs, they're handled later */ continue; if (pcidev->vpd_port != INT_MAX) continue; pcidev->embedded_index = index; pcidev->embedded_index_valid = 1; index++; } return 0; } static int virtfn_filter(const struct dirent *dent) { return (!strncmp(dent->d_name,"virtfn",6)); } /* Assign Virtual Function to Physical Function */ static void set_sriov(struct libbiosdevname_state *state, struct pci_device *pf, const char *virtpath) { struct pci_device *vf; char pci_name[32]; char path[PATH_MAX], cpath[PATH_MAX]; unsigned vf_index; if (sscanf(virtpath, "virtfn%u", &vf_index) != 1) return; unparse_pci_name(pci_name, sizeof(pci_name), pf->pci_dev); snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/%s", pci_name, virtpath); memset(cpath, 0, sizeof(cpath)); if (readlink(path, cpath, sizeof(cpath) - 1) < 0) return; if ((vf = find_dev_by_pci_name(state, cpath)) != NULL) { vf->is_sriov_virtual_function = 1; vf->vf_index = vf_index; vf->pf = pf; pf->is_sriov_physical_function = 1; if (pf->smbios_enabled) { vf->smbios_instance = pf->smbios_instance; vf->physical_slot = pf->physical_slot; } list_add_tail(&vf->vfnode, &pf->vfs); } } static void scan_sriov(struct libbiosdevname_state *state) { struct pci_device *pf; char path[PATH_MAX]; char pci_name[32]; struct dirent **namelist; int n; list_for_each_entry(pf, &state->pci_devices, node) { unparse_pci_name(pci_name, sizeof(pci_name), pf->pci_dev); snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s", pci_name); namelist = NULL; n = scandir(path, &namelist, virtfn_filter, versionsort); if (n <= 0) continue; while (n--) { set_sriov(state, pf, namelist[n]->d_name); free(namelist[n]); } free(namelist); } } /* * This sorts the PCI devices by breadth-first domain/bus/dev/fn. */ static int sort_pci(const struct pci_device *a, const struct pci_device *b) { if (pci_domain_nr(a->pci_dev) < pci_domain_nr(b->pci_dev)) return -1; else if (pci_domain_nr(a->pci_dev) > pci_domain_nr(b->pci_dev)) return 1; if (a->pci_dev->bus < b->pci_dev->bus) return -1; else if (a->pci_dev->bus > b->pci_dev->bus) return 1; if (a->pci_dev->dev < b->pci_dev->dev) return -1; else if (a->pci_dev->dev > b->pci_dev->dev) return 1; if (a->pci_dev->func < b->pci_dev->func) return -1; else if (a->pci_dev->func > b->pci_dev->func) return 1; return 0; } static void insertion_sort_devices(struct pci_device *a, struct list_head *list, int (*cmp)(const struct pci_device *, const struct pci_device *)) { struct pci_device *b; list_for_each_entry(b, list, node) { if (cmp(a, b) <= 0) { list_move_tail(&a->node, &b->node); return; } } list_move_tail(&a->node, list); } static void sort_device_list(struct libbiosdevname_state *state) { LIST_HEAD(sorted_devices); struct pci_device *dev, *tmp; list_for_each_entry_safe(dev, tmp, &state->pci_devices, node) { insertion_sort_devices(dev, &sorted_devices, sort_pci); } list_splice(&sorted_devices, &state->pci_devices); } int get_pci_devices(struct libbiosdevname_state *state) { struct pci_access *pacc; struct pci_dev *p; struct routing_table *table; table = pirq_alloc_read_table(); if (table) state->pirq_table = table; pacc = pci_alloc(); if (!pacc) return 0; #if 0 pci_set_param(pacc, "dump.name", "lspci.txt"); pacc->method = PCI_ACCESS_DUMP; #endif state->pacc = pacc; pci_init(pacc); pci_scan_bus(pacc); for (p=pacc->devices; p; p=p->next) { add_pci_dev(state, p); } /* ordering here is important */ dmidecode_main(state); /* this will fail on Xen guests, that's OK */ sort_device_list(state); scan_sriov(state); set_pci_vpd_instance(state); set_pci_slots(state); set_embedded_index(state); set_pci_slot_index(state); return 0; } int unparse_pci_name(char *buf, int size, const struct pci_dev *pdev) { return snprintf(buf, size, "%04x:%02x:%02x.%x", pci_domain_nr(pdev), pdev->bus, pdev->dev, pdev->func); } static int unparse_location(char *buf, const int size, const int location) { char *s = buf; if (location == 0) s += snprintf(s, size-(s-buf), "embedded"); else if (location == INT_MAX) s += snprintf(s, size-(s-buf), "unknown"); else if (location > 0) s += snprintf(s, size-(s-buf), "%u", location); else s += snprintf(s, size-(s-buf), "unknown"); return (s-buf); } static int unparse_smbios_type41_type(char *buf, const int size, const int type) { char *s = buf; const char *msg[] = {"Other", "Unknown", "Video", "SCSI Controller", "Ethernet", "Token Ring", "Sound", "PATA Controller", "SATA Controller", "SAS Controller", }; if (type > 0 && type <= (sizeof(msg)/sizeof(msg[0]))) s += snprintf(s, size-(s-buf), "%s\n", msg[type-1]); else s += snprintf(s, size-(s-buf), "<OUT OF SPEC>\n"); return (s-buf); } int unparse_pci_device(char *buf, const int size, const struct pci_device *p) { char *s = buf; struct pci_device *dev; char pci_name[16]; s += snprintf(s, size-(s-buf), "PCI name : "); s += unparse_pci_name(s, size-(s-buf), p->pci_dev); s += snprintf(s, size-(s-buf), "\n"); s += snprintf(s, size-(s-buf), "PCI Slot : "); if (p->physical_slot < INT_MAX) s += unparse_location(s, size-(s-buf), p->physical_slot); else s += snprintf(s, size-(s-buf), "Unknown"); s += snprintf(s, size-(s-buf), "\n"); if (p->smbios_type) { s += snprintf(s, size-(s-buf), "SMBIOS Device Type: "); s += unparse_smbios_type41_type(s, size-(s-buf), p->smbios_type); if (p->smbios_instance) s += snprintf(s, size-(s-buf), "SMBIOS Instance: %u\n", p->smbios_instance); } if (p->uses_smbios & HAS_SMBIOS_LABEL && p->smbios_label) s += snprintf(s, size-(s-buf), "SMBIOS Label: %s\n", p->smbios_label); if (p->uses_sysfs & HAS_SYSFS_INDEX) s += snprintf(s, size-(s-buf), "sysfs Index: %u\n", p->sysfs_index); if (p->uses_sysfs & HAS_SYSFS_LABEL) s += snprintf(s, size-(s-buf), "sysfs Label: %s\n", p->sysfs_label); if (p->physical_slot > 0 && !p->is_sriov_virtual_function) s += snprintf(s, size-(s-buf), "Index in slot: %u\n", p->index_in_slot); if (p->embedded_index_valid) s += snprintf(s, size-(s-buf), "Embedded Index: %u\n", p->embedded_index); if (p->vpd_port < INT_MAX) { s += snprintf(s, size-(s-buf), "VPD Port: %u\n", p->vpd_port); s += snprintf(s, size-(s-buf), "VPD Index: %u\n", p->vpd_pfi); if (p->vpd_pf) { s += snprintf(s, size-(s-buf), "VPD PCI master: "); s += unparse_pci_name(s, size-(s-buf), p->vpd_pf->pci_dev); s += snprintf(s, size-(s-buf), " count %d\n", p->vpd_pf->vpd_count); } } if (!list_empty(&p->vfs)) { s += snprintf(s, size-(s-buf), "Virtual Functions:\n"); list_for_each_entry(dev, &p->vfs, vfnode) { unparse_pci_name(pci_name, sizeof(pci_name), dev->pci_dev); s += snprintf(s, size-(s-buf), "%s\n", pci_name); } } return (s-buf); } struct pci_device * find_dev_by_pci(const struct libbiosdevname_state *state, const struct pci_dev *p) { struct pci_device *dev; list_for_each_entry(dev, &state->pci_devices, node) { if (is_same_pci(p, dev->pci_dev)) return dev; } return NULL; } struct pci_device * find_pci_dev_by_pci_addr(const struct libbiosdevname_state *state, const int domain, const int bus, const int device, const int func) { struct pci_device *dev; struct pci_dev p; memset(&p, 0, sizeof(p)); #ifdef HAVE_STRUCT_PCI_DEV_DOMAIN p.domain = domain; #endif p.bus = bus; p.dev = device; p.func = func; list_for_each_entry(dev, &state->pci_devices, node) { if (is_same_pci(&p, dev->pci_dev)) return dev; } return NULL; } struct pci_device * find_dev_by_pci_name(const struct libbiosdevname_state *state, const char *s) { int domain=0, bus=0, device=0, func=0; if (parse_pci_name(s, &domain, &bus, &device, &func)) return NULL; return find_pci_dev_by_pci_addr(state, domain, bus, device, func); } int is_root_port(const struct libbiosdevname_state *state, int domain, int bus, int device, int func) { struct pci_device *pdev; int pos; u16 flag; pdev = find_pci_dev_by_pci_addr(state, domain, bus, device, func); if (!pdev || !pdev->pci_dev) return 0; pos = pci_find_capability(pdev->pci_dev, PCI_CAP_ID_EXP); if (pos != 0) { u8 type; flag = pci_read_word(pdev->pci_dev, pos + PCI_EXP_FLAGS); type = (flag & PCI_EXP_FLAGS_TYPE) >> 4; if (type == PCI_EXP_TYPE_ROOT_PORT) return 1; } return 0; } 07070100000030000081A40000000000000000000000015F52709200000B3E000000000000000000000000000000000000002700000000biosdevname-0.7.3.7.g495ab76/src/pci.h/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #ifndef PCI_H_INCLUDED #define PCI_H_INCLUDED #include <limits.h> #include <pci/pci.h> #include "list.h" #include "state.h" #include "config.h" struct slotlist { struct list_head node; int slot; int count; }; struct pci_port { struct list_head node; int port; int pfi; }; struct pci_device { struct list_head node; struct pci_dev *pci_dev; int physical_slot; unsigned int index_in_slot; /* only valid if physical_slot > 0 and not a VF */ unsigned int embedded_index; /* only valid if embedded_index_valid */ unsigned short int class; unsigned int sbus; unsigned char uses_smbios; unsigned char smbios_type; unsigned char smbios_instance; unsigned char smbios_enabled; char *smbios_label; unsigned int sysfs_index; char * sysfs_label; unsigned char uses_sysfs; unsigned int vf_index; unsigned int vpd_count; unsigned int vpd_pfi; unsigned int vpd_port; struct pci_device *vpd_pf; struct pci_device *pf; struct list_head vfnode; struct list_head vfs; struct list_head ports; unsigned int is_sriov_physical_function:1; unsigned int is_sriov_virtual_function:1; unsigned int embedded_index_valid:1; }; #define HAS_SMBIOS_INSTANCE 1 #define HAS_SMBIOS_LABEL 2 #define HAS_SMBIOS_SLOT 4 #define HAS_SMBIOS_EXACT_MATCH 8 #define HAS_SYSFS_INDEX 1 #define HAS_SYSFS_LABEL 2 #define PHYSICAL_SLOT_UNKNOWN (INT_MAX) #define INDEX_IN_SLOT_UNKNOWN (INT_MAX) extern int get_pci_devices(struct libbiosdevname_state *state); extern void free_pci_devices(struct libbiosdevname_state *state); extern struct pci_device * find_dev_by_pci(const struct libbiosdevname_state *state, const struct pci_dev *p); extern struct pci_device * find_pci_dev_by_pci_addr(const struct libbiosdevname_state *state, const int domain, const int bus, const int device, const int func); extern struct pci_device * find_dev_by_pci_name(const struct libbiosdevname_state *state, const char *s); extern int unparse_pci_device(char *buf, const int size, const struct pci_device *p); extern int unparse_pci_name(char *buf, int size, const struct pci_dev *pdev); static inline int is_pci_network(struct pci_device *dev) { return (dev->class & 0xFF00) == 0x0200; } static inline int is_pci_smbios_type_ethernet(struct pci_device *dev) { return (dev->smbios_type == 0x05); } static inline int is_pci_bridge(struct pci_device *dev) { return (dev->pci_dev->device_class>>8 == 0x06); } #ifdef HAVE_STRUCT_PCI_DEV_DOMAIN static inline int pci_domain_nr(const struct pci_dev *dev) { return dev->domain; } #else static inline int pci_domain_nr(const struct pci_dev *dev) { return 0; } #endif int is_root_port(const struct libbiosdevname_state *state, int domain, int bus, int device, int func); #endif /* PCI_H_INCLUDED */ 07070100000031000081A40000000000000000000000015F52709200001312000000000000000000000000000000000000002800000000biosdevname-0.7.3.7.g495ab76/src/pirq.c/* * PCI IRQ Routing Table dumper * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * * Based on the description of said table found at * http://www.microsoft.com/hwdev/busbios/pciirq.htm * Licensed under the GNU General Public license, version 2. */ #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #include <limits.h> #include <sys/mman.h> #include "pirq.h" extern int nopirq; /* If unknown, use INT_MAX so they get sorted last */ int pirq_pci_dev_to_slot(struct routing_table *table, int domain, int bus, int dev) { int i, num_slots; struct slot_entry *slot; if (!table) return INT_MAX; if (domain != 0) /* can't represent non-zero domains in PIRQ */ return INT_MAX; num_slots = (table->size - 32) / sizeof(*slot); for (i=0; i<num_slots; i++) { slot = &table->slot[i]; if (slot->bus == bus && PCI_DEVICE(slot->device) == dev) { if (slot->slot >= '1' && slot->slot <= '9') return slot->slot - '0'; return slot->slot; } } return INT_MAX; } struct routing_table *pirq_read_file() { #ifdef _JPH FILE *fp; char line[128]; struct routing_table *table; char *r; int count, bus, dev, slot; const char *pirq_file = "biosdecode.txt"; /* Get count of entries */ if ((fp = fopen(pirq_file, "r")) == NULL) return NULL; count = 0; while (fgets(line, sizeof(line), fp) != NULL) { if (strstr(line, "Slot Entry") != NULL) count++; } fclose(fp); /* Read table */ table = malloc(sizeof(*table) + count * sizeof(struct slot_entry)); table->size = 32 + (sizeof(struct slot_entry) * count); if ((fp = fopen(pirq_file, "r")) == NULL) return NULL; count = 0; while (fgets(line, sizeof(line), fp) != NULL) { if ((r = strstr(line, "Slot Entry")) == NULL) continue; if (sscanf(r, "Slot Entry %*d: ID %x:%x", &bus, &dev) == 2) { table->slot[count].bus = bus; table->slot[count].device = dev << 3; if ((r = strstr(line, "on-board")) != NULL) table->slot[count].slot = 0; else if ((r = strstr(line, "slot number ")) != NULL) { sscanf(r, "slot number %d", &slot); table->slot[count].slot = slot; } printf("%d = %.2x:%.2x = %d\n", count, bus, dev, table->slot[count].slot); count++; } } fclose(fp); return table; #endif return NULL; } struct routing_table * pirq_alloc_read_table() { struct routing_table *table = NULL; uint16_t size = 0; uint8_t checksum = 0; int i; void *mem; off_t offset=0L; int fd; /* Skip PIRQ table parsing */ if (nopirq) { return NULL; } if ((table = pirq_read_file()) != NULL) return table; fd = open("/dev/mem", O_RDONLY); if(fd==-1) return NULL; mem = mmap(0, 64*1024, PROT_READ, MAP_SHARED, fd, 0xF0000L); if (mem == (void *)-1LL) goto out; while( offset < 0xFFFF) { if(memcmp(mem+offset, "$PIR", 4)==0) { table = (struct routing_table *)(mem+offset); size = table->size; /* quick sanity checks */ if (size == 0) { table = NULL; break; } /* Version must be 1.0 */ if (!((table->version >> 8) == 1 && (table->version & 0xFF) == 0)) { table = NULL; break; } table = malloc(size); if (!table) break; memcpy(table, mem+offset, size); for (i=0; i<size; i++) checksum +=*(((uint8_t *)table)+i); if (checksum) { free (table); table = NULL; } break; } offset += 16; } munmap(mem, 64*1024); out: close(fd); return table; } void pirq_free_table(struct routing_table *table) { if (table) free(table); } #ifdef UNIT_TEST_PIRQ static void pirq_unparse_slot(struct slot_entry *slot) { printf("Slot %d: PCI %x:%x. ", slot->slot, slot->bus, PCI_DEVICE(slot->device)); printf("INTA link %x irq %x ", slot->inta_link, slot->inta_irq); printf("B link %x irq %x ", slot->intb_link, slot->intb_irq); printf("C link %x irq %x ", slot->intc_link, slot->intc_irq); printf("D link %x irq %x ", slot->intd_link, slot->intd_irq); printf("\n"); } static void pirq_unparse_routing_table(struct routing_table *table) { int i, num_slots; struct slot_entry *slot; char buf[5]; buf[4] = 0; memcpy(buf, &table->signature, 4); printf("PCI IRQ Routing Table\n"); printf("Signature: %s\n", buf); printf("Version : %x\n", table->version); printf("Size : %xh\n", table->size); printf("Bus : %x\n", table->router_bus); printf("DevFn : %x\n", table->router_devfn); printf("Exclusive IRQs : %x\n", table->exclusive_irqs); printf("Compatible Router: %x\n", table->compatable_router); num_slots = (table->size - 32) / sizeof(*slot); slot = &table->slot[0]; for (i=0; i<num_slots; i++) { pirq_unparse_slot(&slot[i]); } } int main(int argc, char *argv[]) { struct routing_table *table; table = pirq_alloc_read_table(); if (!table) return 1; pirq_unparse_routing_table(table); pirq_free_table(table); return 0; } #endif 07070100000032000081A40000000000000000000000015F52709200000538000000000000000000000000000000000000002800000000biosdevname-0.7.3.7.g495ab76/src/pirq.h#ifndef PIRQ_H_INCLUDED #define PIRQ_H_INCLUDED /* * PCI IRQ Routing Table dumper * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * * Based on the description of said table found at * http://www.microsoft.com/hwdev/busbios/pciirq.htm * Licensed under the GNU General Public license, version 2. */ #include <stdint.h> #include <stdlib.h> typedef unsigned char __u8; typedef unsigned short int __u16; typedef unsigned int __u32; struct slot_entry { __u8 bus; __u8 device; __u8 inta_link; __u16 inta_irq; __u8 intb_link; __u16 intb_irq; __u8 intc_link; __u16 intc_irq; __u8 intd_link; __u16 intd_irq; __u8 slot; __u8 reserved; } __attribute__((packed)); struct routing_table { __u32 signature; __u16 version; __u16 size; __u8 router_bus; __u8 router_devfn; __u16 exclusive_irqs; __u32 compatable_router; __u32 miniport_data; __u8 reserved[11]; __u8 checksum; struct slot_entry slot[1]; } __attribute__((packed)); #define PCI_DEVICE(devfn) (((devfn) >> 3) & 0x1f) #define PCI_FUNC(devfn) ((devfn) & 0x07) extern struct routing_table * pirq_alloc_read_table(void); extern void pirq_free_table(struct routing_table *table); extern int pirq_pci_dev_to_slot(struct routing_table *table, int domain, int bus, int dev); #endif /* PIRQ_H_INCLUDED */ 07070100000033000081A40000000000000000000000015F52709200000814000000000000000000000000000000000000002D00000000biosdevname-0.7.3.7.g495ab76/src/read_proc.c/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. * Copied from from net-tools-1.60, also under the GNU GPL v2, * and modified for use here. */ #define _GNU_SOURCE #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include <errno.h> #include "eths.h" #define _PATH_PROCNET_DEV "/proc/net/dev" static struct network_device *add_interface(struct libbiosdevname_state *state, const char *name) { struct network_device *i; i = malloc(sizeof(*i)); if (!i) return NULL; memset(i, 0, sizeof(*i)); INIT_LIST_HEAD(&i->node); strncpy(i->kernel_name, name, sizeof(i->kernel_name)-1); list_add_tail(&i->node, &state->network_devices); return i; } static char *get_name(char **namep, char *p) { int count = 0; char *name; while (isspace(*p)) p++; name = *namep = p; while (*p) { if (isspace(*p)) break; if (*p == ':') { /* could be an alias */ char *dot = p, *dotname = name; *name++ = *p++; count++; while (isdigit(*p)){ *name++ = *p++; count++; if (count == (IFNAMSIZ-1)) break; } if (*p != ':') { /* it wasn't, backup */ p = dot; name = dotname; } if (*p == '\0') return NULL; p++; break; } *name++ = *p++; count++; if (count == (IFNAMSIZ-1)) break; } *name++ = '\0'; return p; } int get_interfaces(struct libbiosdevname_state *state) { FILE *fh; int err; char *line = NULL; size_t linelen = 0; fh = fopen(_PATH_PROCNET_DEV, "r"); if (!fh) { fprintf(stderr, "Error: cannot open %s (%s).\n", _PATH_PROCNET_DEV, strerror(errno)); return 1; } if (getline(&line, &linelen, fh) == -1 /* eat line */ || getline(&line, &linelen, fh) == -1) { err = -1; goto out; } err = 0; while (getline(&line, &linelen, fh) != -1) { char *name; get_name(&name, line); add_interface(state, name); } if (ferror(fh)) err = -1; out: free(line); fclose(fh); return err; } 07070100000034000081A40000000000000000000000015F5270920000021F000000000000000000000000000000000000002900000000biosdevname-0.7.3.7.g495ab76/src/state.h/* * Copyright (c) 2006 Dell, Inc. * by Matt Domsch <Matt_Domsch@dell.com> * Licensed under the GNU General Public license, version 2. */ #ifndef LIBBIOSDEVICE_STATE_H_INCLUDED #define LIBBIOSDEVICE_STATE_H_INCLUDED #include <pci/pci.h> #include "list.h" #include "pirq.h" struct libbiosdevname_state { struct list_head bios_devices; struct list_head pci_devices; struct list_head network_devices; struct list_head slots; struct pci_access *pacc; struct routing_table *pirq_table; }; #endif /* LIBBIOSDEVICESTATE_H_INCLUDED */ 07070100000035000081A40000000000000000000000015F52709200000538000000000000000000000000000000000000002900000000biosdevname-0.7.3.7.g495ab76/src/sysfs.c#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <string.h> /** * sysfs_path_is_file: Check if the path supplied points to a file * @path: path to validate * Returns 0 if path points to file, 1 otherwise * Copied from sysfsutils-2.1.0 (which is LGPL2.1 or later), relicensed GPLv2 for use here. */ int sysfs_path_is_file(const char * path) { struct stat astats; if (!path) { errno = EINVAL; return 1; } if ((lstat(path, &astats)) != 0) { return 1; } if (S_ISREG(astats.st_mode)) return 0; return 1; } int sysfs_read_file(const char * path, char **output) { int ret; char *result = NULL, *n; int fd; unsigned long resultsize = 0; ssize_t length = 0; resultsize = getpagesize(); result = malloc(resultsize); if (!result) return -ENOMEM; memset(result, 0, resultsize); fd = open(path, O_RDONLY); if (fd < 0) { ret = fd; goto free_out; } length = read(fd, result, resultsize-1); close(fd); if (length < 0) { ret = -1; goto free_out; } result[length] = '\0'; if ((n = strchr(result, '\n')) != NULL) *n = '\0'; *output = result; ret = 0; goto out; free_out: free(result); out: return ret; } 07070100000036000081A40000000000000000000000015F5270920000006E000000000000000000000000000000000000002900000000biosdevname-0.7.3.7.g495ab76/src/sysfs.hextern int sysfs_path_is_file(const char *path); extern int sysfs_read_file(const char *path, char **output); 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!720 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor