config.m4 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. dnl $Id$
  2. dnl config.m4 for extension ebpf
  3. dnl Comments in this file start with the string 'dnl'.
  4. dnl Remove where necessary. This file will not work
  5. dnl without editing.
  6. dnl If your extension references something external, use with:
  7. dnl PHP_ARG_WITH(ebpf, for ebpf support,
  8. dnl Make sure that the comment is aligned:
  9. dnl [ --with-ebpf Include ebpf support])
  10. dnl Otherwise use enable:
  11. PHP_ARG_ENABLE(ebpf, whether to enable ebpf support,
  12. dnl Make sure that the comment is aligned:
  13. [ --enable-ebpf Enable ebpf support])
  14. if test "$PHP_EBPF" != "no"; then
  15. dnl Write more examples of tests here...
  16. dnl # --with-ebpf -> check with-path
  17. dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
  18. dnl SEARCH_FOR="/include/ebpf.h" # you most likely want to change this
  19. dnl if test -r $PHP_EBPF/$SEARCH_FOR; then # path given as parameter
  20. dnl EBPF_DIR=$PHP_EBPF
  21. dnl else # search default path list
  22. dnl AC_MSG_CHECKING([for ebpf files in default path])
  23. dnl for i in $SEARCH_PATH ; do
  24. dnl if test -r $i/$SEARCH_FOR; then
  25. dnl EBPF_DIR=$i
  26. dnl AC_MSG_RESULT(found in $i)
  27. dnl fi
  28. dnl done
  29. dnl fi
  30. dnl
  31. dnl if test -z "$EBPF_DIR"; then
  32. dnl AC_MSG_RESULT([not found])
  33. dnl AC_MSG_ERROR([Please reinstall the ebpf distribution])
  34. dnl fi
  35. dnl # --with-ebpf -> add include path
  36. dnl PHP_ADD_INCLUDE($EBPF_DIR/include)
  37. AC_ARG_WITH([ebpf],
  38. [AS_HELP_STRING([--with-bcc=DIR], [Specify the path to bcc headers and libraries])],
  39. [LIB_BCC="$withval"],
  40. [LIB_BCC="deps/bcc"]
  41. )
  42. BCC_C_SOURCE="$LIB_BCC/src/cc"
  43. PHP_ADD_INCLUDE($BCC_C_SOURCE)
  44. dnl AC_ARG_WITH([ebpf],
  45. dnl [AS_HELP_STRING([--with-llvm=DIR], [Specify the path to llvm headers and libraries])],
  46. dnl [LIB_LLVM="$withval"],
  47. dnl [LIB_LLVM="/usr/lib/llvm-14"]
  48. dnl )
  49. PHP_ADD_INCLUDE($LIB_LLVM/include)
  50. dnl AC_ARG_WITH([ebpf],
  51. dnl [AS_HELP_STRING([--with-kernel=DIR], [Specify the path to llvm headers and libraries])],
  52. dnl [LIB_KERNEL="$withval"],
  53. dnl [LIB_KERNEL="/lib/modules/5.15.0-130-generic"]
  54. dnl )
  55. AC_DEFINE_UNQUOTED([KERNEL_MODULES_DIR], ["$LIB_KERNEL"], [Path to kernel modules])
  56. API_SOURCE="api"
  57. PHP_ADD_INCLUDE($API_SOURCE)
  58. PHP_ADD_LIBRARY_WITH_PATH(bcc, /usr/lib/x86_64-linux-gnu, EBPF_SHARED_LIBADD)
  59. dnl # --with-ebpf -> check for lib and symbol presence
  60. dnl LIBNAME=ebpf # you may want to change this
  61. dnl LIBSYMBOL=ebpf # you most likely want to change this
  62. dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
  63. dnl [
  64. dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $EBPF_DIR/$PHP_LIBDIR, EBPF_SHARED_LIBADD)
  65. dnl AC_DEFINE(HAVE_EBPFLIB,1,[ ])
  66. dnl ],[
  67. dnl AC_MSG_ERROR([wrong ebpf lib version or lib not found])
  68. dnl ],[
  69. dnl -L$EBPF_DIR/$PHP_LIBDIR -lm
  70. dnl ])
  71. dnl
  72. PHP_SUBST(EBPF_SHARED_LIBADD)
  73. PHP_REQUIRE_CXX()
  74. PHP_ADD_LIBRARY(stdc++, 1, EBPF_SHARED_LIBADD)
  75. CXXFLAGS="$CXXFLAGS -Wall -Wno-unused-function -Wno-deprecated -Wno-deprecated-declarations -std=c++11"
  76. dnl PHP_NEW_EXTENSION(ebpf, ebpf.cpp, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
  77. source_file="ebpf.cpp \
  78. $API_SOURCE/BPF.cc \
  79. $API_SOURCE/BPFTable.cc"
  80. PHP_NEW_EXTENSION(ebpf, $source_file, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
  81. fi