1SUMMARY = "C library and tools for interacting with the linux GPIO character device"
2RECIPE_MAINTAINER = "Bartosz Golaszewski <brgl@bgdev.pl>"
3
4inherit autotools pkgconfig ptest
5
6SRC_URI += " \
7    https://www.kernel.org/pub/software/libs/libgpiod/libgpiod-${PV}.tar.xz \
8    file://run-ptest \
9"
10
11PACKAGECONFIG[cxx] = "--enable-bindings-cxx,--disable-bindings-cxx"
12
13# Enable cxx bindings by default.
14PACKAGECONFIG ?= " \
15    cxx \
16    ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)} \
17"
18
19# Always build tools - they don't have any additional
20# requirements over the library.
21EXTRA_OECONF = "--enable-tools"
22
23DEPENDS += "autoconf-archive-native"
24
25PACKAGES =+ "${PN}-tools libgpiodcxx"
26FILES:${PN}-tools += " \
27    ${bindir}/gpiodetect \
28    ${bindir}/gpioinfo \
29    ${bindir}/gpioget \
30    ${bindir}/gpioset \
31    ${bindir}/gpiomon \
32"
33FILES:libgpiodcxx = "${libdir}/libgpiodcxx.so.*"
34
35RRECOMMENDS:${PN}-ptest += "coreutils"
36
37do_install:append() {
38    rm -f ${D}${bindir}/gpiod-test
39    rm -f ${D}${bindir}/gpio-tools-test
40    rm -f ${D}${bindir}/gpio-tools-test.bats
41    rm -f ${D}${bindir}/gpiod-cxx-test
42}
43
44do_install_ptest() {
45    install -d ${D}${PTEST_PATH}/tests/
46
47    # These are the core C library tests
48    install -m 0755 ${B}/tests/.libs/gpiod-test ${D}${PTEST_PATH}/tests/
49
50    # Tools are always built so let's always install them for ptest even if
51    # we're not selecting libgpiod-tools.
52    for tool in ${FILES:${PN}-tools}; do
53        install ${B}/tools/.libs/$(basename $tool) ${D}${PTEST_PATH}/tests/
54    done
55
56    if ${@bb.utils.contains('PACKAGECONFIG', 'cxx', 'true', 'false', d)}; then
57        install -m 0755 ${B}/bindings/cxx/tests/.libs/gpiod-cxx-test ${D}${PTEST_PATH}/tests/
58    fi
59}
60
61