summary refs log tree commit diff
path: root/pkgs/development/libraries/libpfm/default.nix
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2023-11-16 22:06:22 +0100
committerVladimír Čunát <v@cunat.cz>2023-11-16 22:06:22 +0100
commita7a8f8253db3f32cc15baf527d36ef7171425eba (patch)
tree5de25f1c82e7892f6aec7b3e5ddb718ff0c50df2 /pkgs/development/libraries/libpfm/default.nix
parentf31242fcfd14e870eb6898fc8849bc4dee883054 (diff)
parent391aafc3d6b17ed5517795eb8b9c41ed7c6082e3 (diff)
Merge #263535: staging-next 2023-10-26
Diffstat (limited to 'pkgs/development/libraries/libpfm/default.nix')
-rw-r--r--pkgs/development/libraries/libpfm/default.nix33
1 files changed, 23 insertions, 10 deletions
diff --git a/pkgs/development/libraries/libpfm/default.nix b/pkgs/development/libraries/libpfm/default.nix
index 8618986195e82..0598fd6451ef5 100644
--- a/pkgs/development/libraries/libpfm/default.nix
+++ b/pkgs/development/libraries/libpfm/default.nix
@@ -1,16 +1,30 @@
-{ lib, stdenv, fetchurl
+{ lib
+, stdenv
+, fetchurl
 , enableShared ? !stdenv.hostPlatform.isStatic
+, windows
 }:
 
-stdenv.mkDerivation (rec {
+stdenv.mkDerivation (finalAttrs: {
   version = "4.13.0";
   pname = "libpfm";
 
   src = fetchurl {
-    url = "mirror://sourceforge/perfmon2/libpfm4/${pname}-${version}.tar.gz";
+    url = "mirror://sourceforge/perfmon2/libpfm4/libpfm-${finalAttrs.version}.tar.gz";
     sha256 = "sha256-0YuXdkx1VSjBBR03bjNUXQ62DG6/hWgENoE/pbBMw9E=";
   };
 
+  # 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)'
+  '';
+
   makeFlags = [
     "PREFIX=${placeholder "out"}"
     "LDCONFIG=true"
@@ -19,6 +33,9 @@ stdenv.mkDerivation (rec {
   ];
 
   env.NIX_CFLAGS_COMPILE = "-Wno-error";
+  env.CONFIG_PFMLIB_SHARED = if enableShared then "y" else "n";
+
+  buildInputs = lib.optional stdenv.hostPlatform.isWindows windows.libgnurx;
 
   meta = with lib; {
     description = "Helper library to program the performance monitoring events";
@@ -29,11 +46,7 @@ stdenv.mkDerivation (rec {
       (PMU) of modern processors.
     '';
     license = licenses.gpl2;
-    maintainers = [ maintainers.pierron ];
-    platforms = platforms.linux;
+    maintainers = with maintainers; [ pierron t4ccer ];
+    platforms = platforms.linux ++ platforms.windows;
   };
-} // lib.optionalAttrs ( ! enableShared )
-{
-  CONFIG_PFMLIB_SHARED = "n";
-}
-)
+})