#include "util/data.h"
 
 #include <sys/prctl.h>
+#ifdef HAVE_TIMERFD_SUPPORT
 #include <sys/timerfd.h>
+#endif
 
 #include <termios.h>
 #include <semaphore.h>
                INIT_LIST_HEAD(&kvm->kvm_events_cache[i]);
 }
 
+#ifdef HAVE_TIMERFD_SUPPORT
 static void clear_events_cache_stats(struct list_head *kvm_events_cache)
 {
        struct list_head *head;
                }
        }
 }
+#endif
 
 static int kvm_events_hash_fn(u64 key)
 {
                pr_info("\nLost events: %" PRIu64 "\n\n", kvm->lost_events);
 }
 
+#ifdef HAVE_TIMERFD_SUPPORT
 static int process_lost_event(struct perf_tool *tool,
                              union perf_event *event __maybe_unused,
                              struct perf_sample *sample __maybe_unused,
        kvm->lost_events++;
        return 0;
 }
+#endif
 
 static bool skip_sample(struct perf_kvm_stat *kvm,
                        struct perf_sample *sample)
        return true;
 }
 
+#ifdef HAVE_TIMERFD_SUPPORT
 /* keeping the max events to a modest level to keep
  * the processing of samples per mmap smooth.
  */
 out:
        return rc;
 }
+#endif
 
 static int read_events(struct perf_kvm_stat *kvm)
 {
        return kvm_events_report_vcpu(kvm);
 }
 
+#ifdef HAVE_TIMERFD_SUPPORT
 static struct perf_evlist *kvm_live_event_list(void)
 {
        struct perf_evlist *evlist;
 
        return err;
 }
+#endif
 
 static void print_kvm_stat_usage(void)
 {
        if (!strncmp(argv[1], "rep", 3))
                return kvm_events_report(&kvm, argc - 1 , argv + 1);
 
+#ifdef HAVE_TIMERFD_SUPPORT
        if (!strncmp(argv[1], "live", 4))
                return kvm_events_live(&kvm, argc - 1 , argv + 1);
+#endif
 
 perf_stat:
        return cmd_stat(argc, argv, NULL);
 
   endif
 endif
 
+$(call feature_check,timerfd)
+ifeq ($(feature-timerfd), 1)
+  CFLAGS += -DHAVE_TIMERFD_SUPPORT
+else
+  msg := $(warning No timerfd support. Disables 'perf kvm stat live');
+endif
+
 disable-python = $(eval $(disable-python_code))
 define disable-python_code
   CFLAGS += -DNO_LIBPYTHON
 
--- /dev/null
+/*
+ * test for timerfd functions used by perf-kvm-stat-live
+ */
+#include <sys/timerfd.h>
+
+int main(void)
+{
+       struct itimerspec new_value;
+
+       int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
+       if (fd < 0)
+               return 1;
+
+       if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
+               return 1;
+
+       return 0;
+}