#
# spec file for package i2c-tools
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           i2c-tools
Version:        4.0
Release:        2.2
Summary:        A heterogeneous set of I2C tools for Linux
License:        GPL-2.0+
Group:          Development/Tools/Other
Requires:       udev
Recommends:     modules
Url:            https://i2c.wiki.kernel.org/index.php/I2C_Tools
Source0:        https://www.kernel.org/pub/software/utils/i2c-tools/%{name}-%{version}.tar.xz
Source1:        https://www.kernel.org/pub/software/utils/i2c-tools/%{name}-%{version}.tar.sign
Patch1:         i2cbusses-path-overflows.patch
Patch2:         build-lib-add-missing-dependencies.patch
Patch3:         decode-dimms-hackweek-DDR4.patch
Patch4:         build-tools-add-missing-dependencies.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
ExcludeArch:    s390 s390x

%description
This package contains a heterogeneous set of I2C tools for Linux: a bus
probing tool, a chip dumper, register-level access helpers, EEPROM
decoding scripts, and more.

%package -n libi2c0
Summary:        I2C/SMBus bus access library
License:        LGPL-2.1+
Group:          System/Libraries

%description -n libi2c0
libi2c offers a way for applications to interact with the devices
connected to the I2C or SMBus buses of the system.

%package -n libi2c0-devel
Summary:        I2C/SMBus bus access library
License:        LGPL-2.1+
Group:          Development/Libraries/C and C++
Requires:       glibc-devel
Requires:       libi2c0 = %{version}
Provides:       /usr/include/i2c/smbus.h

%description -n libi2c0-devel
libi2c offers a way for applications to interact with the devices
connected to the I2C or SMBus buses of the system.

%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1

%build
make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" CC="%{__cc}" BUILD_STATIC_LIB:=0

%install
make install DESTDIR=$RPM_BUILD_ROOT prefix=/usr libdir=%{_libdir} BUILD_STATIC_LIB:=0
# cleanup
rm -f $RPM_BUILD_ROOT/usr/bin/decode-edid

%post -n libi2c0 -p /sbin/ldconfig

%postun -n libi2c0 -p /sbin/ldconfig

%files
%defattr(-,root,root)
/usr/bin/*
/usr/sbin/*
%doc /usr/share/man/man1/*.1.gz
%doc /usr/share/man/man8/*.8.gz

%files -n libi2c0
%{_libdir}/libi2c.so.0*

%files -n libi2c0-devel
%{_libdir}/libi2c.so
%dir /usr/include/i2c
/usr/include/i2c/smbus.h

%changelog
* Tue Dec 12 2017 jdelvare@suse.com
- build-tools-add-missing-dependencies.patch: Fix another random
  failure of parallel builds.
* Wed Dec  6 2017 jdelvare@suse.com
- build-lib-add-missing-dependencies.patch: Fix random failure
  of parallel builds.
- decode-dimms-hackweek-DDR4.patch: Add DDR4 SDRAM memory support
  to decode-dimms (Hackweek 0x10 project.)
* Mon Oct 30 2017 jdelvare@suse.com
- i2cbusses-path-overflows.patch: Prevent buffer overflow of
  sysfs paths.
* Mon Oct 30 2017 jdelvare@suse.com
- Update to version 4.0:
  * New library libi2c
  * Many fixes and improvements to decode-dimms
  * New manual pages and examples added to existing manual pages
  * New tool i2ctransfer
- Removed obsolete decode-dimms-correctly-check-for-out-of-bounds-vendor-id.patch,
  i2c-tools-hackweek-9-dependencies.diff,
  i2c-tools-hackweek-9-improve-DDR3-support.diff,
  i2c-tools-r6048-Move-SMBus-helper-functions.patch,
  i2c-tools-r6053-Add-smbus-header.patch (upstream)
* Mon Jul 17 2017 jdelvare@suse.com
- Add missing bug number in changes file (bsc#1041644).
* Thu Jul  6 2017 jdelvare@suse.com
- decode-dimms-correctly-check-for-out-of-bounds-vendor-id.patch:
  Fix recommended by upstream.
* Thu Jul  6 2017 jdelvare@suse.com
- Update the URL.
- Remove authors list from package description, it does not belong
  there.
* Thu Jul  6 2017 jdelvare@suse.com
- Point to the new download location.
* Tue Sep 27 2016 lchiquitto@suse.de
- Fix file conflict (i2c-dev.h) with linux-glibc-devel. (bsc#995536)
* Fri Nov 27 2015 jdelvare@suse.com
- Update to version 3.1.2:
  * Includes 1 backport we already had
- Removed obsolete i2c-tools-r6250-ddr3-fix-ext-temp-refresh.diff
  (upstream)
* Wed Oct 14 2015 dvaleev@suse.com
- Backport  r6048 and r6053 in order to not conflict with
  linux-glibc-devel
  i2c-tools-r6048-Move-SMBus-helper-functions.patch
  i2c-tools-r6053-Add-smbus-header.patch
* Thu Jun 19 2014 jdelvare@suse.com
- i2c-tools-r6250-ddr3-fix-ext-temp-refresh.diff: Fix DDR3 extended
  temp range refresh rate decoding.
* Sat Feb 22 2014 jdelvare@suse.de
- Update to version 3.1.1:
  * Includes 13 packports we already had
  * Some additional fixes to decode-dimms
  * New manual pages for decode-dimms, decode-vaio
  * i2c-stub-from-dump tolerance on input dump format was improved
- Removed obsolete i2c-tools-r6063-dont-choke-when-no-eeprom.diff,
  i2c-tools-r6106-vendors-JEP106AG.diff,
  i2c-tools-r6107-vendors-JEP106AJ.diff,
  i2c-tools-r6108-remove-duplicate-ns.diff,
  i2c-tools-r6109-fix-decoding-revision.diff,
  i2c-tools-r6110-i2cdetect-clarify-probing.diff,
  i2c-tools-r6121-typo-sprint.diff,
  i2c-tools-r6122-more-DDR3-module-types.diff,
  i2c-tools-r6151-space-before-MHz.diff,
  i2c-tools-r6152-fix-DDR3-tRAS-decoding.diff,
  i2c-tools-r6153-fix-DDR3-timings-rounding.diff,
  i2c-tools-r6154-round-down-PC3-numbers.diff and
  i2c-tools-r6157-vendors-JEP106AK.diff (upstream)
* Thu Apr 18 2013 jdelvare@suse.de
- i2c-tools-hackweek-9-dependencies.diff: Backport 2 helper
  functions needed by the following patch.
- i2c-tools-hackweek-9-improve-DDR3-support.diff: Improve DDR3
  support. This was my hackweek 9 project.
* Wed Apr 17 2013 jdelvare@suse.de
  Backport fixes from upstream 3.1 branch:
- i2c-tools-r6151-space-before-MHz.diff: Print a space before "MHz"
  to improve readability.
- i2c-tools-r6152-fix-DDR3-tRAS-decoding.diff: Fix DDR3 tRAS
  decoding.
- i2c-tools-r6153-fix-DDR3-timings-rounding.diff: Fix DDR3 core
  timings rounding.
- i2c-tools-r6154-round-down-PC3-numbers.diff: Round down PC3
  numbers to comply with Jedec.
- i2c-tools-r6157-vendors-JEP106AK.diff: Update vendor list based
  on Jedec document JEP106AK.
* Thu Mar 28 2013 mmeister@suse.com
- Added url as source.
  Please see http://en.opensuse.org/SourceUrls
* Wed Feb 13 2013 jdelvare@suse.de
  Backport fixes from upstream 3.1 branch:
- i2c-tools-r6063-dont-choke-when-no-eeprom.diff: Don't choke when
  no EEPROM is found.
- i2c-tools-r6106-vendors-JEP106AG.diff,
- i2c-tools-r6107-vendors-JEP106AJ.diff: Update vendor list based
  on Jedec documents JEP106AG and JEP106AJ.
- i2c-tools-r6108-remove-duplicate-ns.diff: Remove duplicate "ns"
  in SDR timings.
- i2c-tools-r6109-fix-decoding-revision.diff: Fix decoding of SDR
  SPD revision.
- i2c-tools-r6110-i2cdetect-clarify-probing.diff: Clarify the SMBus
  commands used for probing by default.
- i2c-tools-r6121-typo-sprint.diff: Prevent hang on reserved DDR3
  module type, caused by a typo in function name.
- i2c-tools-r6122-more-DDR3-module-types.diff: Decode more DDR3
  module types.
* Wed Feb 13 2013 jdelvare@suse.de
- Don't build and ship programs to access I2C memory. We don't want
  to ship 3 tools doing the same thing, and none of these is good
  enough. There is a reason why upstream doesn't include them by
  default. Oh, and they don't even build.
* Mon Feb 13 2012 coolo@suse.com
- patch license to follow spdx.org standard
* Tue Dec 20 2011 duwe@suse.com
- Build and ship programs to access I2C memory.
* Mon Dec  5 2011 jdelvare@suse.de
- Update to version 3.1.0:
  * Support for block writes (i2cset)
  * at24 driver support (decode-dimms)
  * Slightly improved DDR SDRAM support (decode-dimms)
* Fri Sep 30 2011 uli@suse.com
- cross-build fix: use %%__cc macro
* Mon Dec 13 2010 jdelvare@suse.de
- Update to version 3.0.3:
  * Support for DDR3 SDRAM (decode-dimms)
  * Support for alternative output formats (decode-dimms)
  * Support for multiple dumps (i2c-stub-from-dump)
* Sun Oct 31 2010 jengelh@medozas.de
- Use %%_smp_mflags
* Fri Dec 18 2009 jengelh@medozas.de
- Enable parallel building
* Fri Jul 31 2009 jdelvare@suse.de
- List the signature as a source file.
* Mon Jul 27 2009 jdelvare@suse.de
- Update to version 3.0.2:
  * Improved error handling
  * Buses can now be passed by name
  * Obsolete i2c-tools-r5388-prevent-perl-warning.patch
* Tue Nov 18 2008 jdelvare@suse.de
- i2c-tools-r5388-prevent-perl-warning.patch: Prevent a perl 5.10.0
  warning about SEEK_SET and friends being redefined (#446098).
- Add Recommends: modules.
* Tue Nov 11 2008 ro@suse.de
- drop requires for "modules", not really needed here
  and launches a long rebuild chain
* Mon May  5 2008 jdelvare@suse.de
- Drop static /dev/i2c-0 device node, it's no longer needed (if it
  ever really was.)
* Tue Apr  8 2008 jdelvare@suse.de
- Update to version 3.0.1:
  * New helper script i2c-stub-from-dump
  * Improvements to i2cdump and decode-dimms
* Mon Oct 15 2007 jdelvare@suse.de
- Initial release.