Merge pull request #303276 from philiptaron/avrdude-libelf

avrdude: updates and enablement of compile-time features
This commit is contained in:
Sandro 2024-04-20 20:19:12 +02:00 committed by GitHub
commit e8d09f9978
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 75 additions and 13 deletions

View File

@ -1,16 +1,23 @@
{ lib, stdenv, fetchFromGitHub, cmake, bison, flex, libusb-compat-0_1, libelf { lib, callPackage, stdenv, fetchFromGitHub, cmake, bison, flex, libusb1, elfutils
, libftdi1, readline, libserialport , libftdi1, readline, hidapi, libserialport
# documentation building is broken on darwin # Documentation building doesn't work on Darwin. It fails with:
, docSupport ? (!stdenv.isDarwin), texliveMedium, texinfo, texi2html, unixtools }: # Undefined subroutine &Locale::Messages::dgettext called in ... texi2html
#
# https://github.com/NixOS/nixpkgs/issues/224761
, docSupport ? (!stdenv.hostPlatform.isDarwin), texliveMedium, texinfo, texi2html, unixtools }:
stdenv.mkDerivation rec { let
useElfutils = lib.meta.availableOn stdenv.hostPlatform elfutils;
in
stdenv.mkDerivation (finalAttrs: {
pname = "avrdude"; pname = "avrdude";
version = "7.3"; version = "7.3";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "avrdudes"; owner = "avrdudes";
repo = pname; repo = "avdude";
rev = "v${version}"; rev = "v${finalAttrs.version}";
sha256 = "sha256-JqW3AOMmAfcy+PQRcqviWlxA6GoMSEfzIFt1pRYY7Dw="; sha256 = "sha256-JqW3AOMmAfcy+PQRcqviWlxA6GoMSEfzIFt1pRYY7Dw=";
}; };
@ -21,17 +28,36 @@ stdenv.mkDerivation rec {
texi2html texi2html
]; ];
buildInputs = [ libusb-compat-0_1 libelf libftdi1 libserialport readline ]; buildInputs = [
(if useElfutils then elfutils else finalAttrs.finalPackage.passthru.libelf)
cmakeFlags = lib.optionals docSupport [ hidapi
"-DBUILD_DOC=ON" libusb1
libftdi1
libserialport
readline
]; ];
postPatch = lib.optionalString (!useElfutils) ''
# vendored libelf is a static library
sed -i "s/PREFERRED_LIBELF elf/PREFERRED_LIBELF libelf.a elf/" CMakeLists.txt
'';
# Not used:
# -DHAVE_LINUXGPIO=ON because it's incompatible with libgpiod 2.x
cmakeFlags = lib.optionals docSupport [ "-DBUILD_DOC=ON" ]
++ lib.optionals stdenv.hostPlatform.isLinux [ "-DHAVE_LINUXSPI=ON" "-DHAVE_PARPORT=ON" ];
# dvips output references texlive in comments, resulting in a huge closure # dvips output references texlive in comments, resulting in a huge closure
postInstall = lib.optionalString docSupport '' postInstall = lib.optionalString docSupport ''
rm $out/share/doc/${pname}/*.ps rm $out/share/doc/avrdude/*.ps
''; '';
passthru = {
# Vendored and mutated copy of libelf for avrdudes use.
# Produces a static library only.
libelf = callPackage ./libelf.nix { };
};
meta = with lib; { meta = with lib; {
description = "Command-line tool for programming Atmel AVR microcontrollers"; description = "Command-line tool for programming Atmel AVR microcontrollers";
mainProgram = "avrdude"; mainProgram = "avrdude";
@ -45,4 +71,4 @@ stdenv.mkDerivation rec {
platforms = with platforms; linux ++ darwin; platforms = with platforms; linux ++ darwin;
maintainers = [ maintainers.bjornfor ]; maintainers = [ maintainers.bjornfor ];
}; };
} })

View File

@ -0,0 +1,36 @@
{
lib,
stdenv,
cmake,
fetchFromGitHub,
}:
stdenv.mkDerivation {
pname = "libelf";
version = "0.8.13-unstable-2023-01-14";
src = fetchFromGitHub {
owner = "avrdudes";
repo = "libelf";
rev = "0c55bfe1d3020a20bddf6ce57c0d9d98ccb12586";
hash = "sha256-jz7Ef0Eg673IJVZvVNklY40s13LCuMVAc7FGrRI7scQ=";
};
nativeBuildInputs = [ cmake ];
installPhase = ''
runHook preInstall
mkdir -p $out/lib
cp liblibelf.a $out/lib/libelf.a
cp -r $src/include $out/include
runHook postInstall
'';
meta = {
description = "ELF object file access library (vendored by avrdudes)";
homepage = "https://github.com/avrdudes/libelf";
license = lib.licenses.lgpl2Plus;
platforms = lib.platforms.all;
maintainers = [ lib.maintainers.bjornfor ];
};
}