2023-11-16 04:20:00 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
2021-01-05 17:05:55 +00:00
|
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
2023-11-16 04:20:00 +00:00
|
|
|
, windows
|
2021-01-05 17:05:55 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2023-08-10 07:59:29 +00:00
|
|
|
version = "4.13.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "libpfm";
|
|
|
|
|
|
|
|
src = fetchurl {
|
2023-11-16 04:20:00 +00:00
|
|
|
url = "mirror://sourceforge/perfmon2/libpfm4/libpfm-${finalAttrs.version}.tar.gz";
|
2023-08-10 07:59:29 +00:00
|
|
|
sha256 = "sha256-0YuXdkx1VSjBBR03bjNUXQ62DG6/hWgENoE/pbBMw9E=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
# Don't install libpfm.so on windows as it doesn't exist
|
|
|
|
# This target is created only if `ifeq ($(SYS),Linux)` passes
|
|
|
|
patches = [ ./fix-windows.patch ];
|
|
|
|
|
|
|
|
# Upstream uses "WINDOWS" instead of "Windows" which is incorrect
|
|
|
|
# See: https://github.com/NixOS/nixpkgs/pull/252982#discussion_r1314346216
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace config.mk examples/Makefile \
|
|
|
|
--replace '($(SYS),WINDOWS)' '($(SYS),Windows)'
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
makeFlags = [
|
|
|
|
"PREFIX=${placeholder "out"}"
|
|
|
|
"LDCONFIG=true"
|
|
|
|
"ARCH=${stdenv.hostPlatform.uname.processor}"
|
|
|
|
"SYS=${stdenv.hostPlatform.uname.system}"
|
|
|
|
];
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = "-Wno-error";
|
2023-11-16 04:20:00 +00:00
|
|
|
env.CONFIG_PFMLIB_SHARED = if enableShared then "y" else "n";
|
|
|
|
|
|
|
|
buildInputs = lib.optional stdenv.hostPlatform.isWindows windows.libgnurx;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Helper library to program the performance monitoring events";
|
|
|
|
longDescription = ''
|
|
|
|
This package provides a library, called libpfm4 which is used to
|
|
|
|
develop monitoring tools exploiting the performance monitoring
|
|
|
|
events such as those provided by the Performance Monitoring Unit
|
|
|
|
(PMU) of modern processors.
|
|
|
|
'';
|
|
|
|
license = licenses.gpl2;
|
2023-11-16 04:20:00 +00:00
|
|
|
maintainers = with maintainers; [ pierron t4ccer ];
|
|
|
|
platforms = platforms.linux ++ platforms.windows;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-11-16 04:20:00 +00:00
|
|
|
})
|