libusb1: add option to build with examples

This commit is contained in:
SnIcK 2022-12-26 16:50:13 -06:00
parent 8f421eef7d
commit fff47fb039

View File

@ -1,4 +1,5 @@
{ lib, stdenv { lib
, stdenv
, fetchFromGitHub , fetchFromGitHub
, fetchpatch , fetchpatch
, autoreconfHook , autoreconfHook
@ -8,6 +9,7 @@
, libobjc , libobjc
, IOKit , IOKit
, Security , Security
, withExamples ? false
, withStatic ? false , withStatic ? false
}: }:
@ -31,12 +33,20 @@ stdenv.mkDerivation rec {
dontDisableStatic = withStatic; dontDisableStatic = withStatic;
configureFlags = lib.optional (!enableUdev) "--disable-udev"; configureFlags =
lib.optional (!enableUdev) "--disable-udev"
++ lib.optional (withExamples) "--enable-examples-build";
preFixup = lib.optionalString enableUdev '' preFixup = lib.optionalString enableUdev ''
sed 's,-ludev,-L${lib.getLib udev}/lib -ludev,' -i $out/lib/libusb-1.0.la sed 's,-ludev,-L${lib.getLib udev}/lib -ludev,' -i $out/lib/libusb-1.0.la
''; '';
postInstall = lib.optionalString withExamples ''
mkdir -p $out/{bin,sbin,examples/bin}
cp -r examples/.libs/* $out/examples/bin
ln -s $out/examples/bin/fxload $out/sbin/fxload
'';
meta = with lib; { meta = with lib; {
homepage = "https://libusb.info/"; homepage = "https://libusb.info/";
description = "cross-platform user-mode USB device library"; description = "cross-platform user-mode USB device library";
@ -45,6 +55,6 @@ stdenv.mkDerivation rec {
''; '';
platforms = platforms.all; platforms = platforms.all;
license = licenses.lgpl21Plus; license = licenses.lgpl21Plus;
maintainers = with maintainers; [ prusnak ]; maintainers = with maintainers; [ prusnak realsnick ];
}; };
} }