anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / development / libraries / libusb1 / default.nix
blobf0be68faae8f27fe820b84b84b43a898d2f36282
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , autoreconfHook
5 , doxygen
6 , pkg-config
7 , enableUdev ? stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isStatic && !stdenv.hostPlatform.isAndroid
8 , udev
9 , libobjc
10 , IOKit
11 , Security
12 , withExamples ? false
13 , withStatic ? false
14 , withDocs ? stdenv.buildPlatform.canExecute stdenv.hostPlatform
17 stdenv.mkDerivation rec {
18   pname = "libusb";
19   version = "1.0.27";
21   src = fetchFromGitHub {
22     owner = "libusb";
23     repo = "libusb";
24     rev = "v${version}";
25     sha256 = "sha256-OtzYxWwiba0jRK9X+4deWWDDTeZWlysEt0qMyGUarDo=";
26   };
28   outputs = [ "out" "dev" ] ++ lib.optionals withDocs [ "doc" ];
30   nativeBuildInputs = [
31     pkg-config
32     autoreconfHook
33   ] ++ lib.optionals withDocs [ doxygen ];
34   propagatedBuildInputs =
35     lib.optional enableUdev udev ++
36     lib.optionals stdenv.hostPlatform.isDarwin [ libobjc IOKit Security ];
38   dontDisableStatic = withStatic;
40   # libusb-1.0.rc:11: fatal error: opening dependency file .deps/libusb-1.0.Tpo: No such file or directory
41   dontAddDisableDepTrack = stdenv.hostPlatform.isWindows;
43   configureFlags =
44     lib.optional (!enableUdev) "--disable-udev"
45     ++ lib.optional (withExamples) "--enable-examples-build";
47   postBuild = lib.optionalString withDocs ''
48     make -C doc
49     mkdir -p "$doc/share/doc/libusb"
50     cp -r doc/api-1.0/* "$doc/share/doc/libusb/"
51   '';
53   preFixup = lib.optionalString enableUdev ''
54     sed 's,-ludev,-L${lib.getLib udev}/lib -ludev,' -i $out/lib/libusb-1.0.la
55   '';
57   postInstall = lib.optionalString withExamples ''
58     mkdir -p $out/{bin,sbin,examples/bin}
59     cp -r examples/.libs/* $out/examples/bin
60     ln -s $out/examples/bin/fxload $out/sbin/fxload
61   '';
63   meta = with lib; {
64     homepage = "https://libusb.info/";
65     description = "cross-platform user-mode USB device library";
66     longDescription = ''
67       libusb is a cross-platform user-mode library that provides access to USB devices.
68     '';
69     platforms = platforms.all;
70     license = licenses.lgpl21Plus;
71     maintainers = with maintainers; [ prusnak realsnick ];
72   };