]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Build-System] Add --enable-heap-profiler and --enable-cpu-profiler configure flags.
authorAndrey Volk <andywolk@gmail.com>
Fri, 4 Jun 2021 23:37:58 +0000 (02:37 +0300)
committerAndrey Volk <andywolk@gmail.com>
Sat, 23 Oct 2021 19:00:48 +0000 (22:00 +0300)
configure.ac

index 5a7b9f0cbcb161921217fbfc6acf8016726ba3b5..73e322a6cab13526f3472655a22ec26b4325758a 100644 (file)
@@ -1986,6 +1986,45 @@ if test "${enable_address_sanitizer}" = "yes"; then
   APR_ADDTO(LDFLAGS, -fsanitize=address)
 fi
 
+#  Enable HEAP profiler (requires libgoogle-perftools-dev package)
+AC_ARG_ENABLE(heap_profiler,
+  [AC_HELP_STRING([--enable-heap-profiler],[build with google heap profiler])],
+  [enable_heap_profiler="$enable_heap_profiler"],
+  [enable_heap_profiler="no"])
+
+#  Enable CPU profiler (requires libgoogle-perftools-dev package)
+AC_ARG_ENABLE(cpu_profiler,
+  [AC_HELP_STRING([--enable-cpu-profiler],[build with google cpu profiler])],
+  [enable_cpu_profiler="$enable_cpu_profiler"],
+  [enable_cpu_profiler="no"])
+
+PKG_CHECK_MODULES([TCMALLOC], [libtcmalloc], [have_tcmalloc=yes], [have_tcmalloc=no])
+
+if test "${enable_heap_profiler}" = "yes" || test "${enable_cpu_profiler}" = "yes"; then
+  if test "x$have_tcmalloc" != "xyes" ; then
+    AC_MSG_ERROR([You must install libgoogle-perftools-dev in order to use heap or cpu profiler])
+  fi
+fi
+
+# WARNING: When both enabled you can NOT link them statically and MUST use the special library
+if test "${enable_heap_profiler}" = "yes" && test "${enable_cpu_profiler}" = "yes"; then
+  APR_ADDTO(CFLAGS, -ltcmalloc_and_profiler)
+  APR_ADDTO(CXXFLAGS, -ltcmalloc_and_profiler)
+  APR_ADDTO(LDFLAGS, -ltcmalloc_and_profiler)
+else
+  if test "${enable_heap_profiler}" = "yes"; then
+    APR_ADDTO(CFLAGS, -ltcmalloc)
+    APR_ADDTO(CXXFLAGS, -ltcmalloc)
+    APR_ADDTO(LDFLAGS, -ltcmalloc)
+  fi
+
+  if test "${enable_cpu_profiler}" = "yes"; then
+    APR_ADDTO(CFLAGS, -lprofiler)
+    APR_ADDTO(CXXFLAGS, -lprofiler)
+    APR_ADDTO(LDFLAGS, -lprofiler)
+  fi
+fi
+
 #  Enable fake dlclose
 AC_ARG_ENABLE(fake_dlclose,
   [AC_HELP_STRING([--enable-fake-dlclose],[Do not unload dynamic libraries])],