flashprog: refactor make jlink and gpio support configurable

This commit is contained in:
Funkeleinhorn 2024-02-27 14:14:39 +01:00
parent 5ba311a026
commit 306fe56f63
No known key found for this signature in database
GPG Key ID: C7BEA25A0A335A72

View File

@ -2,15 +2,17 @@
, installShellFiles
, lib
, libftdi1
, libgpiod_1
, libgpiod
, libjaylink
, libusb1
, pciutils
, pkg-config
, stdenv
, withJlink ? true
, withGpio ? stdenv.isLinux
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation {
pname = "flashprog";
version = "1.0.1";
@ -24,24 +26,36 @@ stdenv.mkDerivation rec {
installShellFiles
pkg-config
];
buildInputs = [
libftdi1
libjaylink
libusb1
] ++ lib.optionals (!stdenv.isDarwin) [
libgpiod_1
pciutils
] ++ lib.optionals (withJlink) [
libjaylink
] ++ lib.optionals (withGpio) [
libgpiod
];
makeFlags = [ "PREFIX=$(out)" "libinstall" ]
++ lib.optionals stdenv.isDarwin [ "CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no" ]
++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [ "CONFIG_INTERNAL_X86=no" "CONFIG_INTERNAL_DMI=no" "CONFIG_RAYER_SPI=0" ];
makeFlags =
let
yesNo = flag: if flag then "yes" else "no";
in
[
"libinstall"
"PREFIX=$(out)"
"CONFIG_JLINK_SPI=${yesNo withJlink}"
"CONFIG_LINUX_GPIO_SPI=${yesNo withGpio}"
"CONFIG_ENABLE_LIBPCI_PROGRAMMERS=${yesNo (!stdenv.isDarwin)}"
"CONFIG_INTERNAL_X86=${yesNo (!(stdenv.isDarwin) && stdenv.isx86_64)}"
"CONFIG_INTERNAL_DMI=${yesNo (!(stdenv.isDarwin) && stdenv.isx86_64)}"
"CONFIG_RAYER_SPI=${yesNo (!(stdenv.isDarwin) && stdenv.isx86_64)}"
];
meta = with lib; {
homepage = "https://flashprog.org";
description = "Utility for reading, writing, erasing and verifying flash ROM chips";
license = with licenses; [ gpl2 gpl2Plus ];
license = with licenses; [ gpl2Plus ];
maintainers = with maintainers; [ felixsinger ];
platforms = platforms.all;
mainProgram = "flashprog";