Store USE_DLMALLOC in vppinfra/config.h

Change-Id: Ib596e7f525b83dc7e830bcf6a126cd210216ce86
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/Makefile.am b/src/Makefile.am
index 6a92275..68cff78 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,7 +19,7 @@
 ACLOCAL_AMFLAGS = -I m4
 AM_LIBTOOLFLAGS = --quiet
 
-AM_CFLAGS = @CPU_FLAGS@ @DLMALLOC@ -Wall
+AM_CFLAGS = @CPU_FLAGS@ -Wall
 AM_CXXFLAGS = -Wall -std=gnu++11
 
 SUBDIRS = .
diff --git a/src/configure.ac b/src/configure.ac
index fb7ae81..d4c7a75 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -282,7 +282,7 @@
 AC_SUBST(PRE_DATA_SIZE,		[$with_pre_data])
 AC_SUBST(LOG2_CACHE_LINE_BYTES, [$with_log2_cache_line_bytes])
 AC_SUBST(APICLI,		[-DVPP_API_TEST_BUILTIN=${n_with_apicli}])
-AC_SUBST(DLMALLOC,              [-DUSE_DLMALLOC=${n_enable_dlmalloc}])
+AC_SUBST(DLMALLOC,              [${n_enable_dlmalloc}])
 
 AC_DEFINE_UNQUOTED(DPDK_SHARED_LIB,	[${n_enable_dpdk_shared}])
 AC_DEFINE_UNQUOTED(WITH_LIBSSL,		[${n_with_libssl}])
diff --git a/src/examples/sample-plugin/Makefile.am b/src/examples/sample-plugin/Makefile.am
index 2622f4e..1825a8f 100644
--- a/src/examples/sample-plugin/Makefile.am
+++ b/src/examples/sample-plugin/Makefile.am
@@ -13,7 +13,7 @@
 
 AUTOMAKE_OPTIONS = foreign subdir-objects
 
-AM_CFLAGS = -Wall -I${top_srcdir} -I${top_builddir} @DLMALLOC@
+AM_CFLAGS = -Wall -I${top_srcdir} -I${top_builddir}
 AM_LDFLAGS = -module -shared -avoid-version
 AM_LIBTOOLFLAGS = --quiet
 SUFFIXES = .api.h .api .api.json
diff --git a/src/examples/sample-plugin/configure.ac b/src/examples/sample-plugin/configure.ac
index 57ec6ee..69d9891 100644
--- a/src/examples/sample-plugin/configure.ac
+++ b/src/examples/sample-plugin/configure.ac
@@ -32,9 +32,6 @@
   m4_append([list_of_enabled], [$1], [, ])
 ])
 
-ENABLE_ARG(dlmalloc,    [Enable dlmalloc])
-AC_SUBST(DLMALLOC,              [-DUSE_DLMALLOC=${n_enable_dlmalloc}])
-
 CC_CHECK_FLAG("-Wno-address-of-packed-member")
 AS_IF([test "$cc_flag_check" = yes],
 	[CFLAGS="${CFLAGS} -Wno-address-of-packed-member"], [])
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index e1ead76..12f8ddf 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -14,7 +14,7 @@
 
 AUTOMAKE_OPTIONS = foreign subdir-objects
 
-AM_CFLAGS = @CPU_FLAGS@ @DLMALLOC@ -Wall -I${top_srcdir} -I${top_builddir}
+AM_CFLAGS = @CPU_FLAGS@ -Wall -I${top_srcdir} -I${top_builddir}
 AM_LDFLAGS = -module -shared -avoid-version
 AM_LIBTOOLFLAGS = --quiet
 SUFFIXES = .api.h .api .api.json
diff --git a/src/vpp-api/java/Makefile.am b/src/vpp-api/java/Makefile.am
index 6d60a24..321ba33 100644
--- a/src/vpp-api/java/Makefile.am
+++ b/src/vpp-api/java/Makefile.am
@@ -15,7 +15,7 @@
 ACLOCAL_AMFLAGS = -I m4
 AM_LIBTOOLFLAGS = --quiet
 
-AM_CFLAGS = @CPU_FLAGS@ @DLMALLOC@ -Wall -I${top_srcdir} -I${top_builddir} \
+AM_CFLAGS = @CPU_FLAGS@ -Wall -I${top_srcdir} -I${top_builddir} \
   -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux \
   -I@top_srcdir@/plugins -I@top_builddir@/plugins
 
diff --git a/src/vpp-api/vapi/Makefile.am b/src/vpp-api/vapi/Makefile.am
index e1bd813..07ef46e 100644
--- a/src/vpp-api/vapi/Makefile.am
+++ b/src/vpp-api/vapi/Makefile.am
@@ -15,7 +15,7 @@
 ACLOCAL_AMFLAGS = -I m4
 AM_LIBTOOLFLAGS = --quiet
 
-AM_CFLAGS = @CPU_FLAGS@ @DLMALLOC@ -Wall -I${top_srcdir} -I${top_builddir} -I. -I$(top_srcdir)/vpp-api/
+AM_CFLAGS = @CPU_FLAGS@ -Wall -I${top_srcdir} -I${top_builddir} -I. -I$(top_srcdir)/vpp-api/
 
 AM_LDFLAGS = -shared -avoid-version -rpath /none -no-undefined
 
diff --git a/src/vpp.am b/src/vpp.am
index c5fd48a..e8c0155 100644
--- a/src/vpp.am
+++ b/src/vpp.am
@@ -39,7 +39,7 @@
 # bin_vpp_SOURCES +=				\
 #  vpp/api/gmon.c
 
-bin_vpp_CFLAGS = @APICLI@ @DLMALLOC@
+bin_vpp_CFLAGS = @APICLI@
 
 nobase_include_HEADERS +=			\
   vpp/api/vpe_all_api_h.h			\
diff --git a/src/vppinfra/cache.h b/src/vppinfra/cache.h
index ac08355..7a54d34 100644
--- a/src/vppinfra/cache.h
+++ b/src/vppinfra/cache.h
@@ -45,9 +45,6 @@
  */
 #ifndef CLIB_LOG2_CACHE_LINE_BYTES
 
-/* defines CLIB_LOG2_CACHE_LINE_BYTES */
-#include <vppinfra/config.h>
-
 /* Default cache line size of 64 bytes. */
 #ifndef CLIB_LOG2_CACHE_LINE_BYTES
 #define CLIB_LOG2_CACHE_LINE_BYTES 6
diff --git a/src/vppinfra/clib.h b/src/vppinfra/clib.h
index 42748b0..a6f8824 100644
--- a/src/vppinfra/clib.h
+++ b/src/vppinfra/clib.h
@@ -38,6 +38,8 @@
 #ifndef included_clib_h
 #define included_clib_h
 
+#include <vppinfra/config.h>
+
 /* Standalone means to not assume we are running on a Unix box. */
 #if ! defined (CLIB_STANDALONE) && ! defined (CLIB_LINUX_KERNEL)
 #define CLIB_UNIX
diff --git a/src/vppinfra/config.h.in b/src/vppinfra/config.h.in
index 0947c71..58a9731 100644
--- a/src/vppinfra/config.h.in
+++ b/src/vppinfra/config.h.in
@@ -20,4 +20,5 @@
 #define CLIB_LOG2_CACHE_LINE_BYTES @LOG2_CACHE_LINE_BYTES@
 #endif
 
+#define USE_DLMALLOC @DLMALLOC@
 #endif