[iptables PATCH 1/9] Makefile: Add --enable-profiling configure option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A little convenience to prepare a build for analysis with gcov/gprof.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 .gitignore                |  4 ++++
 configure.ac              | 10 ++++++++++
 extensions/GNUmakefile.in |  2 +-
 iptables/Makefile.am      |  1 +
 libipq/Makefile.am        |  1 +
 libiptc/Makefile.am       |  1 +
 libxtables/Makefile.am    |  1 +
 utils/Makefile.am         |  1 +
 8 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index e55952642ed0d..a206fb4870bc8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,8 @@
 *.a
+*.gcda
+*.gcno
+*.gcno.gcov.json.gz
+*.gcov
 *.la
 *.lo
 *.so
diff --git a/configure.ac b/configure.ac
index 071afaf1515de..ea5d2d49112a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,9 @@ AC_ARG_WITH([xt-lock-name], AS_HELP_STRING([--with-xt-lock-name=PATH],
 	[Path to the xtables lock [[/run/xtables.lock]]]),
 	[xt_lock_name="$withval"],
 	[xt_lock_name="/run/xtables.lock"])
+AC_ARG_ENABLE([profiling],
+	AS_HELP_STRING([--enable-profiling], [build for use of gcov/gprof]),
+	[enable_profiling="$enableval"], [enable_profiling="no"])
 
 AC_MSG_CHECKING([whether $LD knows -Wl,--no-undefined])
 saved_LDFLAGS="$LDFLAGS";
@@ -188,6 +191,11 @@ if [[ -n "$ksourcedir" ]]; then
 fi;
 pkgdatadir='${datadir}/xtables';
 
+if test "x$enable_profiling" = "xyes"; then
+	regular_CFLAGS+=" -fprofile-arcs -ftest-coverage"
+	regular_LDFLAGS+=" -lgcov --coverage"
+fi
+
 define([EXPAND_VARIABLE],
 [$2=[$]$1
 if test $prefix = 'NONE'; then
@@ -205,6 +213,7 @@ eval "$2=[$]$2"
 AC_SUBST([regular_CFLAGS])
 AC_SUBST([regular_CPPFLAGS])
 AC_SUBST([noundef_LDFLAGS])
+AC_SUBST([regular_LDFLAGS])
 AC_SUBST([kinclude_CPPFLAGS])
 AC_SUBST([kbuilddir])
 AC_SUBST([ksourcedir])
@@ -250,6 +259,7 @@ Iptables Configuration:
   nfsynproxy util support:		${enable_nfsynproxy}
   nftables support:			${enable_nftables}
   connlabel support:			${enable_connlabel}
+  profiling support:			${enable_profiling}
 
 Build parameters:
   Put plugins into executable (static):	${enable_static}
diff --git a/extensions/GNUmakefile.in b/extensions/GNUmakefile.in
index 6dad4e02481bd..3c68f8decd13f 100644
--- a/extensions/GNUmakefile.in
+++ b/extensions/GNUmakefile.in
@@ -24,7 +24,7 @@ kinclude_CPPFLAGS  = @kinclude_CPPFLAGS@
 AM_CFLAGS       = ${regular_CFLAGS}
 AM_CPPFLAGS     = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_builddir} -I${top_srcdir}/include -I${top_srcdir} ${kinclude_CPPFLAGS} ${CPPFLAGS} @libnetfilter_conntrack_CFLAGS@ @libnftnl_CFLAGS@
 AM_DEPFLAGS     = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@
-AM_LDFLAGS      = @noundef_LDFLAGS@
+AM_LDFLAGS      = @noundef_LDFLAGS@ @regular_LDFLAGS@
 
 ifeq (${V},)
 AM_LIBTOOL_SILENT = --silent
diff --git a/iptables/Makefile.am b/iptables/Makefile.am
index 0258264c4c705..23f8352d30610 100644
--- a/iptables/Makefile.am
+++ b/iptables/Makefile.am
@@ -2,6 +2,7 @@
 
 AM_CFLAGS        = ${regular_CFLAGS}
 AM_CPPFLAGS      = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_srcdir}/include -I${top_srcdir} ${kinclude_CPPFLAGS} ${libmnl_CFLAGS} ${libnftnl_CFLAGS} ${libnetfilter_conntrack_CFLAGS}
+AM_LDFLAGS       = ${regular_LDFLAGS}
 
 BUILT_SOURCES =
 
diff --git a/libipq/Makefile.am b/libipq/Makefile.am
index 9e3a2ca6c42e2..2cdaf32e03292 100644
--- a/libipq/Makefile.am
+++ b/libipq/Makefile.am
@@ -2,6 +2,7 @@
 
 AM_CFLAGS = ${regular_CFLAGS}
 AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_srcdir}/include
+AM_LDFLAGS = ${regular_LDFLAGS}
 
 libipq_la_SOURCES = libipq.c
 lib_LTLIBRARIES   = libipq.la
diff --git a/libiptc/Makefile.am b/libiptc/Makefile.am
index 464a069628f0c..097842f212bb5 100644
--- a/libiptc/Makefile.am
+++ b/libiptc/Makefile.am
@@ -2,6 +2,7 @@
 
 AM_CFLAGS        = ${regular_CFLAGS}
 AM_CPPFLAGS      = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_srcdir}/include ${kinclude_CPPFLAGS}
+AM_LDFLAGS       = ${regular_LDFLAGS}
 
 pkgconfig_DATA      = libiptc.pc libip4tc.pc libip6tc.pc
 
diff --git a/libxtables/Makefile.am b/libxtables/Makefile.am
index 3bfded8570e08..2f4a12e571b9b 100644
--- a/libxtables/Makefile.am
+++ b/libxtables/Makefile.am
@@ -2,6 +2,7 @@
 
 AM_CFLAGS   = ${regular_CFLAGS}
 AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_srcdir}/include -I${top_srcdir}/iptables -I${top_srcdir} ${kinclude_CPPFLAGS}
+AM_LDFLAGS  = ${regular_LDFLAGS}
 
 lib_LTLIBRARIES       = libxtables.la
 libxtables_la_SOURCES = xtables.c xtoptions.c getethertype.c
diff --git a/utils/Makefile.am b/utils/Makefile.am
index 42bd973730194..327a29e028c4d 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -3,6 +3,7 @@
 AM_CFLAGS = ${regular_CFLAGS}
 AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include \
               -I${top_srcdir}/include ${libnfnetlink_CFLAGS}
+AM_LDFLAGS = ${regular_LDFLAGS}
 
 sbin_PROGRAMS =
 pkgdata_DATA =
-- 
2.34.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux