2020-07-06 04:26:21 +00:00
|
|
|
{ stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, flex
|
|
|
|
, bison
|
|
|
|
, libxml2
|
|
|
|
, python
|
|
|
|
, libusb1
|
2022-11-07 02:13:26 +00:00
|
|
|
, avahiSupport ? true, avahi
|
2022-06-02 00:26:22 +00:00
|
|
|
, libaio
|
2020-07-06 04:26:21 +00:00
|
|
|
, runtimeShell
|
2020-09-17 07:08:54 +00:00
|
|
|
, lib
|
2022-10-25 17:11:37 +00:00
|
|
|
, pkg-config
|
2022-10-25 17:12:34 +00:00
|
|
|
, CFNetwork
|
|
|
|
, CoreServices
|
2018-09-13 04:33:57 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "libiio";
|
2022-10-25 17:11:37 +00:00
|
|
|
version = "0.24";
|
2020-07-06 04:26:21 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "lib" "dev" "python" ];
|
2018-09-13 04:33:57 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2020-07-06 04:26:21 +00:00
|
|
|
owner = "analogdevicesinc";
|
|
|
|
repo = "libiio";
|
|
|
|
rev = "v${version}";
|
2022-10-25 17:11:37 +00:00
|
|
|
sha256 = "sha256-c5HsxCdp1cv5BGTQ/8dc8J893zk9ntbfAudLpqoQ1ow=";
|
2018-09-13 04:33:57 +00:00
|
|
|
};
|
|
|
|
|
2021-05-30 12:20:21 +00:00
|
|
|
# Revert after https://github.com/NixOS/nixpkgs/issues/125008 is
|
|
|
|
# fixed properly
|
|
|
|
patches = [ ./cmake-fix-libxml2-find-package.patch ];
|
|
|
|
|
2020-07-06 04:26:21 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
flex
|
|
|
|
bison
|
2022-10-25 17:11:37 +00:00
|
|
|
pkg-config
|
2020-07-06 04:26:21 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
python
|
|
|
|
libxml2
|
|
|
|
libusb1
|
2022-10-25 17:12:34 +00:00
|
|
|
] ++ lib.optional python.isPy3k python.pkgs.setuptools
|
2022-11-07 02:13:26 +00:00
|
|
|
++ lib.optional avahiSupport avahi
|
2022-10-25 17:12:34 +00:00
|
|
|
++ lib.optional stdenv.isLinux libaio
|
|
|
|
++ lib.optionals stdenv.isDarwin [ CFNetwork CoreServices ];
|
2018-09-13 04:33:57 +00:00
|
|
|
|
2020-07-06 04:26:21 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DUDEV_RULES_INSTALL_DIR=${placeholder "out"}/lib/udev/rules.d"
|
|
|
|
"-DPYTHON_BINDINGS=on"
|
2022-10-25 17:12:34 +00:00
|
|
|
# osx framework is disabled,
|
|
|
|
# the linux-like directory structure is used for proper output splitting
|
|
|
|
"-DOSX_PACKAGE=off"
|
|
|
|
"-DOSX_FRAMEWORK=off"
|
2022-11-07 02:13:26 +00:00
|
|
|
] ++ lib.optionals (!avahiSupport) [
|
|
|
|
"-DHAVE_DNS_SD=OFF"
|
2020-07-06 04:26:21 +00:00
|
|
|
];
|
2019-08-01 16:56:06 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
2020-07-06 04:26:21 +00:00
|
|
|
# Hardcode path to the shared library into the bindings.
|
|
|
|
sed "s#@libiio@#$lib/lib/libiio${stdenv.hostPlatform.extensions.sharedLibrary}#g" ${./hardcode-library-path.patch} | patch -p1
|
|
|
|
|
2019-08-01 16:56:06 +00:00
|
|
|
substituteInPlace libiio.rules.cmakein \
|
|
|
|
--replace /bin/sh ${runtimeShell}
|
|
|
|
'';
|
|
|
|
|
2018-09-27 00:37:32 +00:00
|
|
|
postInstall = ''
|
2020-07-06 04:26:21 +00:00
|
|
|
# Move Python bindings into a separate output.
|
|
|
|
moveToOutput ${python.sitePackages} "$python"
|
2018-09-27 00:37:32 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2018-09-13 04:33:57 +00:00
|
|
|
description = "API for interfacing with the Linux Industrial I/O Subsystem";
|
2020-07-06 04:26:21 +00:00
|
|
|
homepage = "https://github.com/analogdevicesinc/libiio";
|
|
|
|
license = licenses.lgpl21Plus;
|
2022-10-25 17:12:34 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2018-09-13 04:33:57 +00:00
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
|
|
|
};
|
|
|
|
}
|