%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
Summary:	PCI bus related utilities.
Summary(ja):	Linux PCI ユーティリティ
Name:		pciutils
Version:	3.1.10
Release:	1%{?_dist_release}
License:	GPLv2+
URL:		http://atrey.karlin.mff.cuni.cz/~mj/pciutils.shtml
Group:		Applications/System

Source:         %{name}-%{version}.tar.gz
Patch2:		pciutils-2.1.10-scan.patch
Patch3: 	pciutils-havepread.patch
Patch6: 	pciutils-2.2.1-idpath.patch
Patch8:         pciutils-3.0.2-multilib.patch
Patch9:         pciutils-dir-d.patch
Patch10:        pciutils-2.2.10-sparc-support.patch
Patch11:        pciutils-3.0.1-superh-support.patch

Buildroot: 	%{_tmppath}/%{name}-%{version}-root
ExclusiveOS: 	Linux
BuildRequires:  sed
Requires:	hwdata
Requires:	%{name}-libs = %{version}-%{release}


%description
The pciutils package contains various utilities for inspecting and
setting devices connected to the PCI bus. The utilities provided
require kernel version 2.1.82 or newer (which support the
/proc/bus/pci interface).

%description -l ja
このパッケージには PCI バスに接続された各種デバイスの状態を見たり
設定したりする為のユーティリティが収められています．
このパッケージに収められたユーティリティはカーネル 2.1.82 以降
(/proc/bus/pci インタフェースがサポートされているもの) を必要とします．

%package devel
Summary: Linux PCI development library.
Summary(ja):	Linux PCI 開発ライブラリ
Group: Development/Libraries
Requires: %{name}-libs = %{version}-%{release}

%description devel
This package contains a library for inspecting and setting
devices connected to the PCI bus.

%description devel -l ja
このパッケージには PCI バスに接続された各種デバイスの状態を見たり
設定したりするのに必要なライブラリが収められています．

%package libs
Summary: Linux PCI library
Summary(ja): Linux PCI ライブラリ
Group: System Environment/Libraries

%description libs
This package contains a library for inspecting and setting
devices connected to the PCI bus.

%package static
Summary: Linux PCI satic library
Summary(ja): Linux PCI スタッティックライブラリ
Group: System Environment/Libraries
Requires: %{name}-devel = %{version}-%{release}

%description static
This package contains a library for inspecting and setting
devices connected to the PCI bus.

## to build compat32 for x86_64 architecture support
%package -n compat32-%{name}-libs
Summary: Linux PCI library.
Group: Development/Libraries
Requires: compat32-%{name}-devel = %{version}-%{release}
%description -n compat32-%{name}-libs
This package contains a library for inspecting and setting
devices connected to the PCI bus.

%package -n compat32-%{name}-devel
Summary: Linux PCI development library.
Group: Development/Libraries
%description -n compat32-%{name}-devel
This package contains a library for inspecting and setting
devices connected to the PCI bus.

%prep
%setup -q -n pciutils-%{version}
%patch2 -p1 -b .scan
%patch3 -p1 -b .pread
%patch6 -p1 -b .idpath
%patch8 -p1 -b .multilib
%patch9 -p1 -b .dird
%patch10 -p1 -b .sparc
%patch11 -p1 -b .superh

sed -i -e 's/^SRC=.*/SRC="http:\/\/pciids.sourceforge.net\/pci.ids"/' update-pciids.sh

%build
make SHARED="no" ZLIB="no" STRIP="" OPT="$RPM_OPT_FLAGS" PREFIX="/usr" IDSDIR="/usr/share/hwdata" PCI_IDS="pci.ids" %{?_smp_mflags}
mv lib/libpci.a lib/libpci.a.toinstall

make clean

make SHARED="yes" ZLIB="no" STRIP="" OPT="$RPM_OPT_FLAGS" PREFIX="/usr" IDSDIR="/usr/share/hwdata" PCI_IDS="pci.ids" %{?_smp_mflags}

#fix lib vs. lib64 in libpci.pc (static Makefile is used)
sed -i -e "s|^libdir=.*$|libdir=%{_libdir}|" lib/libpci.pc


%install
rm -rf $RPM_BUILD_ROOT

install -d $RPM_BUILD_ROOT/{sbin,%{_mandir}/man8,%{_libdir},%{_libdir}/pkgconfig,%{_includedir}/pci}

install -p lspci setpci update-pciids $RPM_BUILD_ROOT/sbin
install -p lspci.8 setpci.8 update-pciids.8 $RPM_BUILD_ROOT%{_mandir}/man8
install -p  lib/libpci.so.*.*.* $RPM_BUILD_ROOT%{_libdir}
ln -s $(basename $RPM_BUILD_ROOT%{_libdir}/*.so.*.*.*) $RPM_BUILD_ROOT%{_libdir}/libpci.so

mv lib/libpci.a.toinstall lib/libpci.a
install -p lib/libpci.a $RPM_BUILD_ROOT%{_libdir}
/sbin/ldconfig -N $RPM_BUILD_ROOT%{_libdir}
install -p lib/pci.h $RPM_BUILD_ROOT%{_includedir}/pci
install -p lib/header.h $RPM_BUILD_ROOT%{_includedir}/pci
install -p lib/config.h $RPM_BUILD_ROOT%{_includedir}/pci
install -p lib/types.h $RPM_BUILD_ROOT%{_includedir}/pci
install -p lib/libpci.pc $RPM_BUILD_ROOT%{_libdir}/pkgconfig


%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig

%post -n compat32-%{name}-libs -p /sbin/ldconfig

%postun -n compat32-%{name}-libs -p /sbin/ldconfig


%files
%defattr(0644, root, root, 0755)
%{_mandir}/man8/*
%attr(0755, root, root) /sbin/*
%doc README ChangeLog pciutils.lsm

%files devel
%defattr(0644, root, root, 0755)
%{_libdir}/libpci.so
%{_libdir}/pkgconfig/libpci.pc
%{_includedir}/pci

%files libs
%defattr(0644, root, root, 0755)
%{_libdir}/libpci.so.*

%files static
%defattr(0644, root, root, 0755)
%{_libdir}/libpci.a

%if %{build_compat32}
%files -n compat32-%{name}-devel
%defattr(0644, root, root, 0755)
%{_libdir}/libpci.so
%{_libdir}/pkgconfig/libpci.pc
%{_includedir}/pci

%files -n compat32-%{name}-libs
%defattr(0644, root, root, 0755)
%{_libdir}/libpci.so.*
%endif


%clean
rm -rf $RPM_BUILD_ROOT


%changelog
* Sat Nov 03 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.10-1
- new upstream release

* Sun Oct 09 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.8-1
- new upstream release
- remove Patch1 (pciutils-2.2.4-buf.patch)

* Tue Sep 28 2010 Shu KONNO <owa@bg.wakwak.com> 3.1.2-4
- rebuilt with rpm-4.8.1 for pkg-config

* Sat Jul 03 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.2-3
- add Requires: %{name}-libs = %{version}-%{release} (devel package)

* Sun Jul 05 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 3.1.2-2
- removed %%if !%%{build_compat32} case condition

* Tue Apr 28 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 3.1.2-1
- new upstream release
- add shared library
- split shared library to -libs
- split static library to -static

* Fri Nov  7 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 3.0.2-1
- new upstream release

* Sat Aug 16 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 3.0.0-1vl5
- new upstream release

* Fri Aug 15 2008 Shu KONNO <owa@bg.wakwak.com> 2.2.4-1vl5
- applied new versioning policy, spec in utf-8

* Wed Dec 06 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 2.2.4-0vl1
- new upstream release

* Sun Feb 19 2006 Shu KONNO <owa@bg.wakwak.com> 2.2.1-1vl2
- rebuilt for x86_64 architecture support
- added compat32-* packages for x86_64 architecture support

* Sun Dec 18 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.1-1vl1
- updated to 2.2.1 based on fedora package
  * Mon Mar 14 2005 Bill Nottingham <notting@redhat.com> - 2.1.99.test8-8
  - add patch for glibc macros (#151032, <redhat-bugzilla@linuxnetz.de>)
  * Tue Jan 25 2005 Bill Nottingham <notting@redhat.com> - 2.1.99.test8-6
  - remove explicit kernel dep (#146153)

* Sat Nov 16 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 2.1.10-4vl1
- use hwdata for pci.ids database.
- merged with rawhide package.
  - update to 2.1.10
  - fix dir perms on /usr/include/pci
  - don't forcibly strip binaries
  - require hwdata now that pci.ids is there
  - man page is now owned by root

* Fri Nov 23 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.1.8-25vl1
- based on 2.1.8-25 from Rawhide and rebuilt for Vine Linux

* Wed Oct 17 2001 Bill Nottingham <notting@redhat.com>
- dump all the patches, ship pci.ids direct out of sourceforge CVS

* Wed Sep 26 2001 Bill Nottingham <notting@redhat.com>
- broadcom bcm5820 id (#53592)

* Fri Aug 10 2001 Bill Nottingham <notting@redhat.com>
- more ids

* Tue Jul 17 2001 Bill Nottingham <notting@redhat.com>
- add newline in printf in PCI-X patch (#49277)

* Mon Jul  9 2001 Bill Nottingham <notting@redhat.com>
- update broadcom patch
- add new ids from 2.4.6

* Mon May 28 2001 Bill Nottingham <notting@redhat.com>
- add a couple of e1000 ids

* Thu Mar 22 2001 Bill Nottingham <notting@redhat.com>
- another megaraid id

* Wed Mar 21 2001 Bill Nottingham <notting@redhat.com>
- another megaraid id

* Wed Mar 14 2001 Preston Brown <pbrown@redhat.com>
- LSI SCSI PCI id

* Wed Feb 21 2001 Nalin Dahyabhai <nalin@redhat.com>
- fix formatting problems

* Wed Feb 21 2001 Preston Brown <pbrown@redhat.com>
- add IBM ServeRAID entries

* Tue Feb 20 2001 Preston Brown <pbrown@redhat.com>
- i860 entries.

* Mon Feb 19 2001 Helge Deller <hdeller@redhat.de>
- added various pci ids 

* Fri Feb  2 2001 Bill Nottingham <notting@redhat.com>
- fix mishap in fixing mishap

* Thu Feb  1 2001 Bill Nottingham <notting@redhat.com>
- fix apparent mishap in pci.ids update from kernel (#25520)

* Tue Jan 23 2001 Bill Nottingham <notting@redhat.com>
- pci.ids updates

* Tue Dec 12 2000 Bill Nottingham <notting@redhat.com>
- big pile of pci.ids updates

* Tue Jul 25 2000 Nalin Dahyabhai <nalin@redhat.com>
- clean up patches to not generate badly-formatted files

* Tue Jul 25 2000 Preston Brown <pbrown@redhat.com>
- Vortex fixes laroche originally applied on kudzu moved here.

* Fri Jul 14 2000 Preston Brown <pbrown@redhat.com>
- pci ids for i815, new ati hardware

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Tue Jul 11 2000 Bill Nottingham <notting@redhat.com>
- yet more IDs
- PCI-X support from Matt Domsch

* Fri Jul  7 2000 Bill Nottingham <notting@redhat.com>
- some more QLogic ids

* Mon Jun 26 2000 Bill Nottingham <notting@redhat.com>
- more IDs from Dell

* Sat Jun 10 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.8

* Fri Apr 21 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.7

* Mon Apr 17 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.6

* Fri Mar  3 2000 Bill Nottingham <notting@redhat.com>
- add a couple of ids

* Mon Feb 14 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.5

* Thu Feb  3 2000 Bill Nottingham <notting@redhat.com>
- handle compressed man pages

* Mon Jan 24 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.4

* Thu Jan 20 2000 Bill Nottingham <notting@redhat.com>
- update to 2.1.3

* Fri Dec 24 1999 Bill Nottingham <notting@redhat.com>
- update to 2.1.2

* Tue Jun 29 1999 Bill Nottingham <notting@redhat.com>
- add -devel package

* Thu May 20 1999 Bill Nottingham <notting@redhat.com>
- update to 2.0

* Mon Apr 19 1999 Jakub Jelinek  <jj@ultra.linux.cz>
- update to 1.99.5
- fix sparc64 operation

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 2)

* Thu Feb  4 1999 Bill Nottingham <notting@redhat.com>
- initial build
