1{ lib
2, stdenv
3, fetchzip
4, pkg-config
5, fixDarwinDylibNames
6, libusb1
7, systemdMinimal
8, darwin
9}:
10
11stdenv.mkDerivation rec {
12 pname = "libusbsio";
13 version = "2.1.11";
14
15 src = fetchzip {
16 url = "https://www.nxp.com/downloads/en/libraries/libusbsio-${version}-src.zip";
17 sha256 = "sha256-qgoeaGWTWdTk5XpJwoauckEQlqB9lp5x2+TN09vQttI=";
18 };
19
20 postPatch = ''
21 rm -r bin/*
22 '';
23
24 makeFlags = [
25 "CC=${stdenv.cc.targetPrefix}cc"
26 "BINDIR="
27 ];
28
29 nativeBuildInputs = [
30 pkg-config
31 ] ++ lib.optionals stdenv.isDarwin [
32 fixDarwinDylibNames
33 ];
34
35 buildInputs = [
36 libusb1
37 ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
38 AppKit
39 CoreFoundation
40 IOKit
41 ]) ++ lib.optionals stdenv.isLinux [
42 systemdMinimal # libudev
43 ];
44
45 installPhase = ''
46 runHook preInstall
47 install -D bin/libusbsio${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libusbsio${stdenv.hostPlatform.extensions.sharedLibrary}
48 runHook postInstall
49 '';
50
51 meta = with lib; {
52 homepage = "https://www.nxp.com/design/software/development-software/library-for-windows-macos-and-ubuntu-linux:LIBUSBSIO";
53 description = "Library for communicating with devices connected via the USB bridge on LPC-Link2 and MCU-Link debug probes on supported NXP microcontroller evaluation boards";
54 platforms = platforms.all;
55 license = licenses.bsd3;
56 maintainers = with maintainers; [ frogamic sbruder ];
57 };
58}