Turbostat: confine AC_COMPILE_IFELSE() inside a AC_CACHE_CHECK block
[collectd.git] / configure.ac
index 8201981..90420f8 100644 (file)
@@ -590,6 +590,31 @@ have_termios_h="no"
 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
 
 # For the turbostat plugin
+have_asm_msrindex_h="no"
+AC_CHECK_HEADERS(asm/msr-index.h, [have_asm_msrindex_h="yes"])
+
+if test "x$have_asm_msrindex_h" = "xyes"
+then
+  AC_CACHE_CHECK([whether asm/msr-index.h has MSR_CORE_C3_RESIDENCY],
+                 [c_cv_have_usable_asm_msrindex_h],
+                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[[
+#include<asm/msr-index.h>
+]]],
+[[[
+int y = MSR_CORE_C3_RESIDENCY;
+return(y);
+]]]
+  )],
+                 [c_cv_have_usable_asm_msrindex_h="yes"],
+                 [c_cv_have_usable_asm_msrindex_h="no"],
+                                  )
+                 )
+fi
+
+have_cpuid_h="no"
+AC_CHECK_HEADERS(cpuid.h, [have_cpuid_h="yes"])
+
 AC_CHECK_HEADERS(sys/capability.h)
 #
 # Checks for typedefs, structures, and compiler characteristics.
@@ -5177,7 +5202,6 @@ then
        plugin_swap="yes"
        plugin_tcpconns="yes"
        plugin_thermal="yes"
-       plugin_turbostat="yes"
        plugin_uptime="yes"
        plugin_vmem="yes"
        plugin_vserver="yes"
@@ -5188,6 +5212,10 @@ then
        then
                plugin_ipvs="yes"
        fi
+       if test "x$c_cv_have_usable_asm_msrindex_h" = "xyes" && test "x$have_cpuid_h" = "xyes"
+       then
+               plugin_turbostat="yes"
+       fi
 fi
 
 if test "x$ac_system" = "xOpenBSD"