anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / development / libraries / libftdi / 1.x.nix
blob5d579cf8cb3335561fe76b0f2552be4743b255c7
1 { lib
2 , stdenv
3 , fetchgit
4 , cmake
5 , pkg-config
6 , libusb1
7 , libconfuse
8 , cppSupport ? true
9 , boost
10 , pythonSupport ? true
11 , python3
12 , swig
13 , docSupport ? true
14 , doxygen
15 , graphviz
18 let
19   inherit (lib) optionals optionalString;
20   onOff = a: if a then "ON" else "OFF";
22 stdenv.mkDerivation rec {
23   pname = "libftdi";
24   version = "1.5-unstable-2023-12-21";
26   src = fetchgit {
27     url = "git://developer.intra2net.com/libftdi";
28     rev = "de9f01ece34d2fe6e842e0250a38f4b16eda2429";
29     hash = "sha256-U37M5P7itTF1262oW+txbKxcw2lhYHAwy1ML51SDVMs=";
30   };
32   strictDeps = true;
34   nativeBuildInputs = [ cmake pkg-config ]
35     ++ optionals docSupport [ doxygen graphviz ]
36     ++ optionals pythonSupport [ swig ];
38   buildInputs = [ libconfuse ]
39     ++ optionals cppSupport [ boost ];
41   cmakeFlags = [
42     "-DFTDIPP=${onOff cppSupport}"
43     "-DBUILD_TESTS=${onOff cppSupport}"
44     "-DLINK_PYTHON_LIBRARY=${onOff pythonSupport}"
45     "-DPYTHON_BINDINGS=${onOff pythonSupport}"
46     "-DDOCUMENTATION=${onOff docSupport}"
47   ] ++ lib.optionals pythonSupport [
48     "-DPYTHON_EXECUTABLE=${python3.pythonOnBuildForHost.interpreter}"
49     "-DPYTHON_LIBRARY=${python3}/lib/libpython${python3.pythonVersion}${stdenv.hostPlatform.extensions.sharedLibrary}"
50   ];
52   propagatedBuildInputs = [ libusb1 ];
54   postInstall = ''
55     mkdir -p "$out/etc/udev/rules.d/"
56     cp ../packages/99-libftdi.rules "$out/etc/udev/rules.d/"
57   '' + optionalString docSupport ''
58     cp -r doc/man "$out/share/"
59     cp -r doc/html "$out/share/doc/libftdi1/"
60   '';
62   postFixup = optionalString cppSupport ''
63     # This gets misassigned to the C++ version's path for some reason
64     for fileToFix in $out/{bin/libftdi1-config,lib/pkgconfig/libftdi1.pc}; do
65       substituteInPlace $fileToFix \
66         --replace "$out/include/libftdipp1" "$out/include/libftdi1"
67     done
68   '';
70   meta = with lib; {
71     description = "Library to talk to FTDI chips using libusb";
72     homepage = "https://www.intra2net.com/en/developer/libftdi/";
73     license = with licenses; [ lgpl2Only gpl2Only ];
74     platforms = platforms.all;
75     maintainers = with maintainers; [ bjornfor ];
76   };