(define-module (ruther packages radio)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cmake)
#:use-module (guix packages)
#:use-module (guix gexp)
#:use-module (guix utils)
#:use-module (guix git-download)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages flex)
#:use-module (gnu packages bison)
#:use-module (gnu packages python)
#:use-module (gnu packages avahi)
#:use-module (gnu packages linux)
#:use-module (gnu packages libusb)
#:use-module (gnu packages xml)
#:use-module (gnu packages radio))
(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 "-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
avahi
libaio))
(inputs
(list
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 libad9361
(package
(name "libad9361")
(version "0.3")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/analogdevicesinc/libad9361-iio")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32 "1inv39xfg8gqz1v7k1n2a7p9zzlb6gq98gcnnpdcr9fa5alvmvpm"))))
(inputs
(list libiio))
(build-system cmake-build-system)
(license (list
license:lgpl2.1
license:gpl2))
(home-page "https://github.com/analogdevicesinc/libad9361-iio")
(synopsis
"IIO AD9361 library for filter design and handling, multi-chip sync, etc. ")
(description "This is a simple library used for userspace,
which manages multi-chip sync (on platforms (FMCOMMS5) where multiple AD9361 devices are use)
can create AD9361 specific FIR filters on the fly.")))
(define-public sdr++/pluto
(package
(inherit sdr++)
(name "sdr++-pluto")
(arguments
(substitute-keyword-arguments (package-arguments sdr++)
((#:configure-flags flags '())
#~(cons*
"-DOPT_BUILD_PLUTOSDR_SOURCE=ON"
(delete "-DOPT_BUILD_PLUTOSDR_SOURCE=OFF" #$flags)))))
(inputs
(modify-inputs (package-inputs sdr++)
(append libad9361)
(append libiio)))))
(define-public sdrangel-pluto
(package
(inherit sdrangel)
(name "sdrangel-pluto")
(arguments
(substitute-keyword-arguments (package-arguments sdrangel)
((#:configure-flags flags '())
#~(cons*
(string-append "-DIIO_DIR=" #$(this-package-input "libiio"))
#$flags))))
(inputs
(modify-inputs (package-inputs sdrangel)
(append libad9361)
(append libiio)))))