about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libpfm
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-11-19 16:49:21 +0100
committerAlyssa Ross <hi@alyssa.is>2023-11-19 16:51:12 +0100
commitb9c0b3f126472b144c543d8d77a8047e8d905ada (patch)
tree2ad99b8789bcb62b993ed18d2877905f7f02bdac /nixpkgs/pkgs/development/libraries/libpfm
parent67419f0e56f99b0ebbe14574d3492110ac84c8d6 (diff)
parentc757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad (diff)
downloadnixlib-b9c0b3f126472b144c543d8d77a8047e8d905ada.tar
nixlib-b9c0b3f126472b144c543d8d77a8047e8d905ada.tar.gz
nixlib-b9c0b3f126472b144c543d8d77a8047e8d905ada.tar.bz2
nixlib-b9c0b3f126472b144c543d8d77a8047e8d905ada.tar.lz
nixlib-b9c0b3f126472b144c543d8d77a8047e8d905ada.tar.xz
nixlib-b9c0b3f126472b144c543d8d77a8047e8d905ada.tar.zst
nixlib-b9c0b3f126472b144c543d8d77a8047e8d905ada.zip
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs into HEAD
Conflicts:
	nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix
	nixpkgs/pkgs/top-level/perl-packages.nix
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libpfm')
-rw-r--r--nixpkgs/pkgs/development/libraries/libpfm/default.nix33
-rw-r--r--nixpkgs/pkgs/development/libraries/libpfm/fix-windows.patch18
2 files changed, 41 insertions, 10 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libpfm/default.nix b/nixpkgs/pkgs/development/libraries/libpfm/default.nix
index 8618986195e8..0598fd6451ef 100644
--- a/nixpkgs/pkgs/development/libraries/libpfm/default.nix
+++ b/nixpkgs/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";
-}
-)
+})
diff --git a/nixpkgs/pkgs/development/libraries/libpfm/fix-windows.patch b/nixpkgs/pkgs/development/libraries/libpfm/fix-windows.patch
new file mode 100644
index 000000000000..584b9ba6eb81
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libpfm/fix-windows.patch
@@ -0,0 +1,18 @@
+diff --git a/lib/Makefile b/lib/Makefile
+index 5ca71e3..cd0717f 100644
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -428,11 +428,13 @@ install:
+ 	-mkdir -p $(DESTDIR)$(LIBDIR)
+ 	$(INSTALL) -m 644 $(ALIBPFM) $(DESTDIR)$(LIBDIR)
+ ifeq ($(CONFIG_PFMLIB_SHARED),y)
++ifeq ($(SYS),Linux)
+ 	$(INSTALL) $(SLIBPFM) $(DESTDIR)$(LIBDIR)
+ 	cd $(DESTDIR)$(LIBDIR); $(LN) $(SLIBPFM) $(VLIBPFM)
+ 	cd $(DESTDIR)$(LIBDIR); $(LN) $(SLIBPFM) libpfm.$(SOLIBEXT)
+ 	-$(LDCONFIG)
+ endif
++endif
+ 
+ tags:
+ 	$(CTAGS) -o $(TOPDIR)/tags --tag-relative=yes $(SRCS) $(INCDEP)