2021-04-05 15:23:46 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchgit
|
|
|
|
, cmake
|
|
|
|
, pkg-config
|
|
|
|
, libusb1
|
|
|
|
, libconfuse
|
|
|
|
, cppSupport ? true
|
|
|
|
, boost
|
|
|
|
, pythonSupport ? true
|
|
|
|
, python3
|
|
|
|
, swig
|
|
|
|
, docSupport ? true
|
|
|
|
, doxygen
|
|
|
|
, graphviz
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
let
|
|
|
|
inherit (lib) optionals optionalString;
|
|
|
|
onOff = a: if a then "ON" else "OFF";
|
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2021-04-05 15:23:46 +00:00
|
|
|
pname = "libftdi";
|
|
|
|
version = "1.5";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
src = fetchgit {
|
|
|
|
url = "git://developer.intra2net.com/libftdi";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "0vipg3y0kbbzjhxky6hfyxy42mpqhvwn1r010zr5givcfp8ghq26";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-09-11 15:47:08 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config ]
|
|
|
|
++ optionals docSupport [ doxygen graphviz ]
|
|
|
|
++ optionals pythonSupport [ swig ];
|
|
|
|
|
|
|
|
buildInputs = [ libconfuse ]
|
2022-09-11 15:47:08 +00:00
|
|
|
++ optionals cppSupport [ boost ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DFTDIPP=${onOff cppSupport}"
|
|
|
|
"-DBUILD_TESTS=${onOff cppSupport}"
|
|
|
|
"-DLINK_PYTHON_LIBRARY=${onOff pythonSupport}"
|
|
|
|
"-DPYTHON_BINDINGS=${onOff pythonSupport}"
|
|
|
|
"-DDOCUMENTATION=${onOff docSupport}"
|
2023-01-11 07:51:40 +00:00
|
|
|
] ++ lib.optionals pythonSupport [
|
2023-11-16 04:20:00 +00:00
|
|
|
"-DPYTHON_EXECUTABLE=${python3.pythonOnBuildForHost.interpreter}"
|
2022-09-11 15:47:08 +00:00
|
|
|
"-DPYTHON_LIBRARY=${python3}/lib/libpython${python3.pythonVersion}${stdenv.hostPlatform.extensions.sharedLibrary}"
|
2021-04-05 15:23:46 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = [ libusb1 ];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p "$out/etc/udev/rules.d/"
|
|
|
|
cp ../packages/99-libftdi.rules "$out/etc/udev/rules.d/"
|
2021-04-05 15:23:46 +00:00
|
|
|
'' + optionalString docSupport ''
|
2020-04-24 23:36:52 +00:00
|
|
|
cp -r doc/man "$out/share/"
|
2021-04-05 15:23:46 +00:00
|
|
|
cp -r doc/html "$out/share/doc/libftdi1/"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = optionalString cppSupport ''
|
|
|
|
# This gets misassigned to the C++ version's path for some reason
|
|
|
|
for fileToFix in $out/{bin/libftdi1-config,lib/pkgconfig/libftdi1.pc}; do
|
|
|
|
substituteInPlace $fileToFix \
|
|
|
|
--replace "$out/include/libftdipp1" "$out/include/libftdi1"
|
|
|
|
done
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Library to talk to FTDI chips using libusb";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://www.intra2net.com/en/developer/libftdi/";
|
2021-04-05 15:23:46 +00:00
|
|
|
license = with licenses; [ lgpl2Only gpl2Only ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ bjornfor ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|