022c9c
commit 98b21b2bcf013f59b67b8c4c5944282fa93a6be5
022c9c
Author: Frank Ch. Eigler <fche@redhat.com>
022c9c
Date:   Tue Jun 26 12:16:04 2018 -0400
022c9c
022c9c
    configury: add --without-bpf configure option
022c9c
    
022c9c
    Fully autoconf'ing bpf capabilities is error-prone, so provide a blunt
022c9c
    instrument.
022c9c
022c9c
diff --git a/configure b/configure
022c9c
index 9a8a41b..b7a8790 100755
022c9c
--- a/configure
022c9c
+++ b/configure
022c9c
@@ -917,6 +917,7 @@ with_dyninst
022c9c
 enable_virt
022c9c
 with_python2_probes
022c9c
 with_python3_probes
022c9c
+with_bpf
022c9c
 with_selinux
022c9c
 with_java
022c9c
 with_extra_version
022c9c
@@ -1639,6 +1640,7 @@ Optional Packages:
022c9c
   --without-python3-probes
022c9c
                           Disable building python version 3 probe support,
022c9c
                           even if it is available
022c9c
+  --without-bpf           Do not try to build BPF components
022c9c
   --without-selinux       Do not use libselinux even if present
022c9c
   --with-java=DIRECTORY   Specify JDK directory to compile libHelperSDT.so
022c9c
                           against (default is /usr/lib/jvm/java)
022c9c
@@ -12297,9 +12299,16 @@ if test $stap_cv_sectionq = yes; then
022c9c
 fi
022c9c
 
022c9c
 
022c9c
-$as_echo "#define HAVE_BPF_DECLS 0" >>confdefs.h
022c9c
 
022c9c
-ac_fn_c_check_decl "$LINENO" "BPF_PROG_TYPE_PERF_EVENT" "ac_cv_have_decl_BPF_PROG_TYPE_PERF_EVENT" "#include <linux/bpf.h>
022c9c
+# Check whether --with-bpf was given.
022c9c
+if test "${with_bpf+set}" = set; then :
022c9c
+  withval=$with_bpf;
022c9c
+fi
022c9c
+
022c9c
+
022c9c
+if test "x$with_bpf" != "xno"; then :
022c9c
+
022c9c
+    ac_fn_c_check_decl "$LINENO" "BPF_PROG_TYPE_PERF_EVENT" "ac_cv_have_decl_BPF_PROG_TYPE_PERF_EVENT" "#include <linux/bpf.h>
022c9c
 "
022c9c
 if test "x$ac_cv_have_decl_BPF_PROG_TYPE_PERF_EVENT" = xyes; then :
022c9c
   ac_have_decl=1
022c9c
@@ -12311,10 +12320,13 @@ cat >>confdefs.h <<_ACEOF
022c9c
 #define HAVE_DECL_BPF_PROG_TYPE_PERF_EVENT $ac_have_decl
022c9c
 _ACEOF
022c9c
 if test $ac_have_decl = 1; then :
022c9c
-  $as_echo "#define HAVE_BPF_DECLS 1" >>confdefs.h
022c9c
+
022c9c
+$as_echo "#define HAVE_BPF_DECLS 1" >>confdefs.h
022c9c
 
022c9c
 fi
022c9c
 
022c9c
+
022c9c
+fi
022c9c
  if test "x$ac_cv_have_decl_BPF_PROG_TYPE_PERF_EVENT" == "xyes"; then
022c9c
   HAVE_BPF_DECLS_TRUE=
022c9c
   HAVE_BPF_DECLS_FALSE='#'
022c9c
@@ -12323,7 +12335,6 @@ else
022c9c
   HAVE_BPF_DECLS_FALSE=
022c9c
 fi
022c9c
 
022c9c
-
022c9c
 ac_config_files="$ac_config_files includes/sys/sdt-config.h po/Makefile.in"
022c9c
 
022c9c
 
022c9c
diff --git a/configure.ac b/configure.ac
022c9c
index ea7ffdc..12fc337 100644
022c9c
--- a/configure.ac
022c9c
+++ b/configure.ac
022c9c
@@ -789,14 +789,20 @@ if test $stap_cv_sectionq = yes; then
022c9c
   support_section_question=1
022c9c
 fi
022c9c
 
022c9c
-dnl Check if we have <linux/bpf.h> for bpf backend.
022c9c
-AC_DEFINE([HAVE_BPF_DECLS], [0], [Define to 1 if you have the necessary declarations in bpf.h])
022c9c
-AC_CHECK_DECLS([BPF_PROG_TYPE_PERF_EVENT],
022c9c
-               [AC_DEFINE([HAVE_BPF_DECLS], [1])],
022c9c
+
022c9c
+AC_ARG_WITH([bpf],
022c9c
+  AS_HELP_STRING([--without-bpf],[Do not try to build BPF components]))
022c9c
+
022c9c
+dnl Allow --without-bpf to disable this autodetection, as some kernels
022c9c
+dnl have some headers but missing some decls like __NR_bpf.  Too hard
022c9c
+dnl to detect all the prereqs here.
022c9c
+AS_IF([test "x$with_bpf" != "xno"], [
022c9c
+    AC_CHECK_DECLS([BPF_PROG_TYPE_PERF_EVENT],
022c9c
+               [AC_DEFINE([HAVE_BPF_DECLS], [1], [Define to 1 if you have the necessary declarations in bpf.h])],
022c9c
                [],
022c9c
                [#include <linux/bpf.h>])
022c9c
+    ])
022c9c
 AM_CONDITIONAL(HAVE_BPF_DECLS, [test "x$ac_cv_have_decl_BPF_PROG_TYPE_PERF_EVENT" == "xyes"])
022c9c
-
022c9c
 AC_CONFIG_FILES([includes/sys/sdt-config.h po/Makefile.in])
022c9c
 
022c9c
 if test $build_elfutils = yes -a $enable_translator = yes; then