tcmalloc.m4 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. dnl -------------------------------------------------------- -*- autoconf -*-
  2. dnl SPDX-License-Identifier: Apache-2.0
  3. dnl
  4. dnl tcmalloc.m4: Trafficserver's tcmalloc autoconf macros
  5. dnl modified to skip other TS_ helpers
  6. dnl
  7. dnl This is kinda fugly, but need a way to both specify a directory and which
  8. dnl of the many tcmalloc libraries to use ...
  9. AC_DEFUN([TS_CHECK_TCMALLOC], [
  10. AC_ARG_WITH([tcmalloc-lib],
  11. [AS_HELP_STRING([--with-tcmalloc-lib],[specify the tcmalloc library to use [default=tcmalloc]])],
  12. [
  13. with_tcmalloc_lib="$withval"
  14. ],[
  15. with_tcmalloc_lib="tcmalloc"
  16. ]
  17. )
  18. has_tcmalloc=0
  19. AC_ARG_WITH([tcmalloc], [AS_HELP_STRING([--with-tcmalloc=DIR], [use the tcmalloc library])],
  20. [
  21. if test "$withval" != "no"; then
  22. if test "x${enable_jemalloc}" = "xyes"; then
  23. AC_MSG_ERROR([Cannot compile with both tcmalloc and jemalloc])
  24. fi
  25. tcmalloc_have_lib=0
  26. if test "x$withval" != "xyes" && test "x$withval" != "x"; then
  27. tcmalloc_ldflags="$withval/lib"
  28. LDFLAGS="${LDFLAGS} -L${tcmalloc_ldflags}"
  29. LIBTOOL_LINK_FLAGS="${LIBTOOL_LINK_FLAGS} -rpath ${tcmalloc_ldflags}"
  30. fi
  31. AC_CHECK_LIB(${with_tcmalloc_lib}, tc_cfree, [tcmalloc_have_lib=1])
  32. if test "$tcmalloc_have_lib" != "0"; then
  33. LIBS="${LIBS} -l${with_tcmalloc_lib}"
  34. has_tcmalloc=1
  35. AC_DEFINE(has_tcmalloc, [1], [Link/compile against tcmalloc])
  36. else
  37. AC_MSG_ERROR([Couldn't find a tcmalloc installation])
  38. fi
  39. fi
  40. ])
  41. AC_SUBST(has_tcmalloc)
  42. ])