[bug#77927,v3,1/4] gnu: Add libiio

Message ID 0ddebef4bfce7c9902f29f395296374240a95ac4.1745167600.git.rutherther@ditigal.xyz
State New
Headers
Series Fix cross compilation |

Commit Message

Rutherther April 20, 2025, 4:47 p.m. UTC
  This is a dependency used for communicating with PlutoSDR.

* gnu/packages/radio.scm (libiio): New variable.

Change-Id: Ic34895af35fa008923fed0de74ad12ffc75f2021
---
 gnu/packages/radio.scm | 70 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
  

Patch

diff --git a/gnu/packages/radio.scm b/gnu/packages/radio.scm
index 2752380a3a..283b69bfd7 100644
--- a/gnu/packages/radio.scm
+++ b/gnu/packages/radio.scm
@@ -49,6 +49,7 @@  (define-module (gnu packages radio)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
@@ -56,6 +57,7 @@  (define-module (gnu packages radio)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages engineering)
+  #:use-module (gnu packages flex)
   #:use-module (gnu packages fltk)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages gd)
@@ -190,6 +192,74 @@  (define-public libcorrect
 used as a drop-in substitute for @code{libfec}.")
       (license license:bsd-3))))
 
+(define-public libiio
+  (package
+    (name "libiio")
+    (version "0.26")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/analogdevicesinc/libiio")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "18cmaszfmn6kaa9gi26kkgjk506xqb8zsd4bq6yp8hzxr1qldfly"))))
+    (arguments
+     (list
+      #:tests? #f
+      #:configure-flags
+      #~(list
+         (string-append "-DPKG_CONFIG_EXECUTABLE="
+                        (search-input-file %build-inputs
+                                           (string-append "/bin/" #$(pkg-config-for-target))))
+         (string-append "-DUDEV_RULES_INSTALL_DIR=" #$output "/lib/udev/rules.d")
+         "-DOSX_PACKAGE=off"
+         "-DOSX_FRAMEWORK=off"
+         (string-append "-DPython_EXECUTABLE=" (search-input-file %build-inputs "/bin/python3"))
+         "-DPYTHON_BINDINGS=on")
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'patch
+            (lambda _
+              (substitute* "bindings/python/iio.py"
+                (("_iiolib = \"iio\"") (string-append "_iiolib = \"" #$output "/lib/libiio.so\""))
+                (("find_library\\(_iiolib\\)") "_iiolib"))
+              ;; Libiio is not installed at the time of the build. The check is unnecessary,
+              ;; to do it the upstream way, we would have to configure, build, install
+              ;; without the bindings first, and then second time with the bindings...
+              (substitute* "bindings/python/setup.py.cmakein"
+                (("self._check_libiio_installed()") "")))))))
+    (native-inputs
+     (list
+      pkg-config
+      flex
+      bison
+      python))
+    (inputs
+     (list
+      avahi
+      libaio
+      libxml2
+      libusb))
+    (build-system cmake-build-system)
+    (license (list
+              license:lgpl2.1
+              license:gpl2))
+    (home-page "https://github.com/analogdevicesinc/libiio")
+    (synopsis "A cross platform library for interfacing with local and remote Linux IIO devices ")
+    (description
+     "Library for interfacing with Linux IIO devices
+libiio is used to interface to the Linux Industrial Input/Output (IIO) Subsystem.
+The Linux IIO subsystem is intended to provide support for devices that in some
+sense are analog to digital or digital to analog converters (ADCs, DACs).
+This includes, but is not limited to ADCs, Accelerometers, Gyros, IMUs,
+Capacitance to Digital Converters (CDCs), Pressure Sensors, Color, Light and Proximity Sensors,
+Temperature Sensors, Magnetometers, DACs, DDS (Direct Digital Synthesis), PLLs (Phase Locked Loops),
+Variable/Programmable Gain Amplifiers (VGA, PGA), and RF transceivers. You can use libiio natively
+on an embedded Linux target (local mode), or use libiio to communicate remotely to that same target
+from a host Linux, Windows or MAC over USB or Ethernet or Serial.")))
+
 (define-public liquid-dsp
   (package
     (name "liquid-dsp")