4cbaa0f3a3bbc2432280f1afe8723b96fddd9884
[gentoo.git] / dev-embedded / libftdi / libftdi-0.20-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_6 )
7 inherit cmake-utils python-single-r1
8
9 if [[ ${PV} == 9999* ]] ; then
10         inherit git-r3
11         EGIT_REPO_URI="git://developer.intra2net.com/${PN}"
12 else
13         SRC_URI="http://www.intra2net.com/en/developer/${PN}/download/${P}.tar.gz"
14         KEYWORDS="amd64 arm ~arm64 ppc ppc64 sparc x86"
15 fi
16
17 DESCRIPTION="Userspace access to FTDI USB interface chips"
18 HOMEPAGE="http://www.intra2net.com/en/developer/libftdi/"
19
20 LICENSE="LGPL-2"
21 SLOT="0"
22 IUSE="cxx doc examples python"
23 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
24
25 RDEPEND="virtual/libusb:0
26         cxx? ( dev-libs/boost )
27         python? ( ${PYTHON_DEPS} )"
28 DEPEND="${RDEPEND}
29         python? ( dev-lang/swig )
30         doc? ( app-doc/doxygen )"
31
32 PATCHES=(
33         "${FILESDIR}"/${P}-cmake-include.patch
34         "${FILESDIR}"/${P}-cmake-version.patch
35 )
36
37 pkg_setup() {
38         use python && python-single-r1_pkg_setup
39 }
40
41 src_prepare() {
42         if use python; then
43                 sed -i \
44                         -e "s:[$]{PYTHON_LIB_INSTALL}/../site-packages:$(python_get_sitedir):" \
45                         bindings/CMakeLists.txt || die
46         fi
47         sed -i \
48                 -e '/SET(LIB_SUFFIX /d' \
49                 CMakeLists.txt || die
50
51         cmake-utils_src_prepare
52 }
53
54 src_configure() {
55         local mycmakeargs=(
56                 -DFTDIPP=$(usex cxx)
57                 -DDOCUMENTATION=$(usex doc)
58                 -DEXAMPLES=$(usex examples)
59                 -DPYTHON_BINDINGS=$(usex python)
60                 -DCMAKE_SKIP_BUILD_RPATH=ON
61         )
62         cmake-utils_src_configure
63 }
64
65 src_install() {
66         cmake-utils_src_install
67         use python && python_optimize
68         dodoc ChangeLog README
69
70         if use doc ; then
71                 # Clean up crap man pages. #356369
72                 rm -vf "${CMAKE_BUILD_DIR}"/doc/man/man3/{_,usb_,deprecated}*
73
74                 doman "${CMAKE_BUILD_DIR}"/doc/man/man3/*
75                 dodoc -r "${CMAKE_BUILD_DIR}"/doc/html
76         fi
77         if use examples ; then
78                 docinto examples
79                 dodoc examples/*.c
80         fi
81 }