python313Packages.traits: fix build (#373698)
[NixPkgs.git] / pkgs / development / libraries / libftdi / 1.x.nix
blob89f3a991e9a3147acd149c9e94ee0953c4cc5b96
1 { lib
2 , stdenv
3 , fetchgit
4 , fetchpatch
5 , cmake
6 , pkg-config
7 , libusb1
8 , libconfuse
9 , cppSupport ? true
10 , boost
11 , pythonSupport ? true
12 , python3
13 , swig
14 , docSupport ? true
15 , doxygen
16 , graphviz
19 let
20   inherit (lib) optionals optionalString;
21   onOff = a: if a then "ON" else "OFF";
23 stdenv.mkDerivation rec {
24   pname = "libftdi";
25   version = "1.5-unstable-2023-12-21";
27   src = fetchgit {
28     url = "git://developer.intra2net.com/libftdi";
29     rev = "de9f01ece34d2fe6e842e0250a38f4b16eda2429";
30     hash = "sha256-U37M5P7itTF1262oW+txbKxcw2lhYHAwy1ML51SDVMs=";
31   };
33   patches = [
34     (fetchpatch {
35       # http://developer.intra2net.com/mailarchive/html/libftdi/2024/msg00024.html
36       # https://bugzilla.redhat.com/show_bug.cgi?id=2319133
37       name = "swig-4.3.0-fix.patch";
38       url = "https://src.fedoraproject.org/rpms/libftdi/raw/9051ea9ea767eced58b69d855a5d700a5d4602cc/f/libftdi-1.5-swig-4.3.patch";
39       hash = "sha256-X5tqiPewnyAyvLzR6s0VbNpZKLd0idtPGU4ro36CZHI=";
40     })
41   ];
43   strictDeps = true;
45   nativeBuildInputs = [ cmake pkg-config ]
46     ++ optionals docSupport [ doxygen graphviz ]
47     ++ optionals pythonSupport [ swig ];
49   buildInputs = [ libconfuse ]
50     ++ optionals cppSupport [ boost ];
52   cmakeFlags = [
53     "-DFTDIPP=${onOff cppSupport}"
54     "-DBUILD_TESTS=${onOff cppSupport}"
55     "-DLINK_PYTHON_LIBRARY=${onOff pythonSupport}"
56     "-DPYTHON_BINDINGS=${onOff pythonSupport}"
57     "-DDOCUMENTATION=${onOff docSupport}"
58   ] ++ lib.optionals pythonSupport [
59     "-DPYTHON_EXECUTABLE=${python3.pythonOnBuildForHost.interpreter}"
60     "-DPYTHON_LIBRARY=${python3}/lib/libpython${python3.pythonVersion}${stdenv.hostPlatform.extensions.sharedLibrary}"
61   ];
63   propagatedBuildInputs = [ libusb1 ];
65   postInstall = ''
66     mkdir -p "$out/etc/udev/rules.d/"
67     cp ../packages/99-libftdi.rules "$out/etc/udev/rules.d/"
68   '' + optionalString docSupport ''
69     cp -r doc/man "$out/share/"
70     cp -r doc/html "$out/share/doc/libftdi1/"
71   '';
73   meta = with lib; {
74     description = "Library to talk to FTDI chips using libusb";
75     homepage = "https://www.intra2net.com/en/developer/libftdi/";
76     license = with licenses; [ lgpl2Only gpl2Only ];
77     platforms = platforms.all;
78     maintainers = with maintainers; [ bjornfor ];
79   };