diff --git a/configure.ac b/configure.ac index 5f626dbd..7939f978 100644 --- a/configure.ac +++ b/configure.ac @@ -88,6 +88,11 @@ AC_ARG_WITH([libxml2], [Use libxml2 [default=check]])], [request_libxml2=$withval], [request_libxml2=check]) +AC_ARG_WITH([jemalloc], + [AS_HELP_STRING([--with-jemalloc], + [Use jemalloc [default=check]])], + [request_jemalloc=$withval], [request_jemalloc=check]) + AC_ARG_WITH([cython], [AS_HELP_STRING([--with-cython=PATH], [Use cython in given PATH])], @@ -249,6 +254,23 @@ fi AM_CONDITIONAL([HAVE_LIBXML2], [ test "x${have_libxml2}" = "xyes" ]) +# jemalloc +have_jemalloc=no +if test "x${request_jemalloc}" != "xno"; then + LIBS_OLD=$LIBS + AC_SEARCH_LIBS([malloc_stats_print], [jemalloc], [have_jemalloc=yes]) + LIBS=$LIBS_OLD + if test "x${have_jemalloc}" = "xyes"; then + JEMALLOC_LIBS="-ljemalloc" + AC_SUBST([JEMALLOC_LIBS]) + fi +fi + +if test "x${request_jemalloc}" = "xyes" && + test "x${have_jemalloc}" != "xyes"; then + AC_MSG_ERROR([jemalloc was requested (--with-jemalloc) but not found]) +fi + # spdylay (for src/nghttpx) PKG_CHECK_MODULES([LIBSPDYLAY], [libspdylay >= 1.2.3], [have_spdylay=yes], [have_spdylay=no]) @@ -450,6 +472,7 @@ AC_MSG_NOTICE([summary of build options: Libevent(SSL): ${have_libevent_openssl} Spdylay: ${have_spdylay} Jansson: ${have_jansson} + Jemalloc: ${have_jemalloc} Applications: ${enable_app} HPACK tools: ${enable_hpack_tools} Examples: ${enable_examples} diff --git a/src/Makefile.am b/src/Makefile.am index 25f0ce74..59b6700a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,6 +43,7 @@ AM_LDFLAGS = \ @LIBEVENT_OPENSSL_LIBS@ \ @OPENSSL_LIBS@ \ @JANSSON_LIBS@ \ + @JEMALLOC_LIBS@ \ @SRC_LIBS@ LDADD = \