--- configure.orig	2024-08-30 16:22:20.000000000 -0400
+++ configure	2025-02-03 19:35:29.403655000 -0500
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /usr/bin/env bash
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.69 for PAPI 7.2.0.0.
 #
@@ -4785,9 +4785,11 @@
 
 		   if test "$family" = "amd64"; then
                       MISCSRCS="$MISCSRCS x86_cpuid_info.c"
+                      CPU=x86
 
 		   elif test "$family" = "i386"; then
                       MISCSRCS="$MISCSRCS x86_cpuid_info.c"
+                      CPU=x86
 		   fi ;;
 
 	       darwin)
@@ -6254,7 +6256,7 @@
       as_fn_error $? "PAPI requires FreeBSD 6 or greater" "$LINENO" 5
     fi
     # Determine if HWPMC module is on the kernel
-    dmesg | grep hwpmc 2> /dev/null > /dev/null
+    sysctl kern.hwpmc 2> /dev/null > /dev/null
     if test "$?" != "0" ; then
       as_fn_error $? "HWPMC module not found. (see INSTALL.TXT)" "$LINENO" 5
     fi
@@ -6795,12 +6797,7 @@
 
 PAPI_NUM_COMP=0
 for comp in $components; do
-  idx=`echo "$comp" | sed -n "s/\/.*//p" | wc -c`
-  if test "$idx" = 0; then
-	subcomp=$comp
-  else
-      subcomp=`echo $comp | sed -E "s/^.{${idx}}//"`
-  fi
+  subcomp=`echo "$comp" | sed 's@.*/@@'`
   COMPONENT_RULES="$COMPONENT_RULES components/$comp/Rules.$subcomp"
   echo "extern papi_vector_t _${subcomp}_vector;" >> components_config.h
   PAPI_NUM_COMP=$((PAPI_NUM_COMP+1))
@@ -6813,12 +6810,7 @@
 fi
 
 for comp in $components; do
-  idx=`echo "$comp" | sed -n "s/\/.*//p" | wc -c`
-  if test "$idx" = 0; then
-	subcomp=$comp
-  else
-      subcomp=`echo $comp | sed -E "s/^.{${idx}}//"`
-  fi
+  subcomp=`echo "$comp" | sed 's@.*/@@'`
   echo "   &_${subcomp}_vector," >> components_config.h
 done
 echo "   NULL" >> components_config.h
@@ -6854,20 +6846,26 @@
   fi
 
   if test "x$comp" = "xsysdetect" ; then
-      if test "x`find $PAPI_CUDA_ROOT -name "cuda.h"`" != "x" ; then
-          CFLAGS="$CFLAGS -DHAVE_CUDA"
-      fi
+      if test -n "$PAPI_CUDA_ROOT" ; then
+          if test "x`find $PAPI_CUDA_ROOT -name "cuda.h"`" != "x" ; then
+              CFLAGS="$CFLAGS -DHAVE_CUDA"
+          fi
 
-      if test "x`find $PAPI_CUDA_ROOT -name "nvml.h"`" != "x" ; then
-		  CFLAGS="$CFLAGS -DHAVE_NVML"
+          if test "x`find $PAPI_CUDA_ROOT -name "nvml.h"`" != "x" ; then
+	      CFLAGS="$CFLAGS -DHAVE_NVML"
 	  fi
+      fi
 
-      if test "x`find $PAPI_ROCM_ROOT -name "hsa.h"`" != "x" ; then
-          CFLAGS="$CFLAGS -DHAVE_ROCM"
+      if test -n "$PAPI_ROCM_ROOT" ; then
+          if test "x`find $PAPI_ROCM_ROOT -name "hsa.h"`" != "x" ; then
+              CFLAGS="$CFLAGS -DHAVE_ROCM"
+          fi
       fi
 
-      if test "x`find $PAPI_ROCMSMI_ROOT -name "rocm_smi.h"`" != "x" ; then
-          CFLAGS="$CFLAGS -DHAVE_ROCM_SMI"
+      if test -n "$PAPI_ROCMSMI_ROOT" ; then
+          if test "x`find $PAPI_ROCMSMI_ROOT -name "rocm_smi.h"`" != "x" ; then
+              CFLAGS="$CFLAGS -DHAVE_ROCM_SMI"
+          fi
       fi
   fi
 done
