*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / sys-apps / i2c-tools / i2c-tools-4.1-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python{2_7,3_6,3_7,3_8} )
7 DISTUTILS_OPTIONAL="1"
8
9 inherit distutils-r1 flag-o-matic toolchain-funcs
10
11 DESCRIPTION="I2C tools for bus probing, chip dumping, EEPROM decoding, and more"
12 HOMEPAGE="https://www.kernel.org/pub/software/utils/i2c-tools"
13 SRC_URI="https://www.kernel.org/pub/software/utils/${PN}/${P}.tar.xz"
14
15 LICENSE="GPL-2"
16 SLOT="0"
17 KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc ~ppc64 ~sparc ~x86"
18 IUSE="perl python static-libs"
19 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
20
21 RDEPEND="
22         python? ( ${PYTHON_DEPS} )"
23 DEPEND="${RDEPEND}"
24 RDEPEND+="
25         perl? ( dev-lang/perl )"
26
27 src_prepare() {
28         default
29         use python && distutils-r1_src_prepare
30
31         # Cut out the eeprom/ & stub/ dirs as only perl scripts live there.
32         if ! use perl ; then
33                 sed -i '/^SRCDIRS/s: eeprom stub : :g' Makefile || die
34         fi
35 }
36
37 src_configure() {
38         use python && distutils-r1_src_configure
39
40         # Always build & use dynamic libs if possible.
41         if tc-is-static-only ; then
42                 export BUILD_DYNAMIC_LIB=0
43                 export USE_STATIC_LIB=1
44                 export BUILD_STATIC_LIB=1
45         else
46                 export BUILD_DYNAMIC_LIB=1
47                 export USE_STATIC_LIB=0
48                 export BUILD_STATIC_LIB=$(usex static-libs 1 0)
49         fi
50 }
51
52 src_compile() {
53         emake AR="$(tc-getAR)" CC="$(tc-getCC)" all-lib # parallel make
54         emake CC="$(tc-getCC)"
55         emake -C eepromer CC="$(tc-getCC)" CFLAGS="${CFLAGS}"
56
57         if use python ; then
58                 cd py-smbus || die
59                 append-cppflags -I../include
60                 distutils-r1_src_compile
61         fi
62 }
63
64 src_install() {
65         emake DESTDIR="${D}" libdir="/usr/$(get_libdir)" PREFIX="/usr" install-lib install
66         dosbin eepromer/eeprom{,er}
67         rm -rf "${D}"/usr/include || die # part of linux-headers
68         dodoc CHANGES README
69         local d
70         for d in $(usex perl eeprom '') eepromer ; do
71                 docinto "${d}"
72                 dodoc "${d}"/README*
73         done
74
75         if use python ; then
76                 cd py-smbus || die
77                 docinto py-smbus
78                 dodoc README*
79                 distutils-r1_src_install
80         fi
81 }