diff mbox series

[1/9] tracecmd: Use make variable instead of if statement for zlib test

Message ID 20220805154040.2014381-2-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 762839a848e3725e20300c66a467259ad79e616b
Headers show
Series trace-cmd library: Add and use new helper functions | expand

Commit Message

Steven Rostedt Aug. 5, 2022, 3:40 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Instead of adding a test in all the Makefiles that test ZLIB_INSTALLED,
just create a variable that has ZLIB_LDLAGS set to -lz when enabled and
pass that to the LIB flags. When it's not enabled, ZLIB_LDLAGS will be
empty.

(I guess LDLAGS should have been LDFLAGS but a typo appears to have gone
 wild!)

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 Makefile               | 3 +++
 lib/trace-cmd/Makefile | 6 +-----
 tracecmd/Makefile      | 6 +-----
 3 files changed, 5 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 2cf66e0d5efc..437b7d5a7152 100644
--- a/Makefile
+++ b/Makefile
@@ -316,10 +316,13 @@  endif
 ZLIB_INSTALLED := $(shell if (printf "$(pound)include <zlib.h>\n void main(){deflateInit(NULL, Z_BEST_COMPRESSION);}" | $(CC) -o /dev/null -x c - -lz >/dev/null 2>&1) ; then echo 1; else echo 0 ; fi)
 ifeq ($(ZLIB_INSTALLED), 1)
 export ZLIB_INSTALLED
+ZLIB_LDLAGS = -lz
 CFLAGS += -DHAVE_ZLIB
 $(info    Have zlib compression support)
 endif
 
+export ZLIB_LDLAGS
+
 TEST_LIBZSTD = $(shell sh -c "$(PKG_CONFIG) --atleast-version 1.4.0 libzstd > /dev/null 2>&1 && echo y")
 
 ifeq ("$(TEST_LIBZSTD)", "y")
diff --git a/lib/trace-cmd/Makefile b/lib/trace-cmd/Makefile
index 9374b163b5f3..a476e35b3762 100644
--- a/lib/trace-cmd/Makefile
+++ b/lib/trace-cmd/Makefile
@@ -51,11 +51,7 @@  $(DEPS): | $(bdir)
 $(LIBTRACECMD_STATIC): $(OBJS)
 	$(Q)$(call do_build_static_lib)
 
-LIBS = $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS) $(LIBZSTD_LDLAGS) -lpthread
-
-ifeq ($(ZLIB_INSTALLED), 1)
-LIBS += -lz
-endif
+LIBS = $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS) $(ZLIB_LDLAGS) $(LIBZSTD_LDLAGS) -lpthread
 
 $(LIBTRACECMD_SHARED_VERSION): $(LIBTRACECMD_SHARED)
 	@ln -sf $(<F) $@
diff --git a/tracecmd/Makefile b/tracecmd/Makefile
index 56be9a3b88d1..8207c54b4391 100644
--- a/tracecmd/Makefile
+++ b/tracecmd/Makefile
@@ -50,13 +50,9 @@  all_objs := $(sort $(ALL_OBJS))
 all_deps := $(all_objs:$(bdir)/%.o=$(bdir)/.%.d)
 
 CONFIG_INCLUDES =
-CONFIG_LIBS	= -lrt -lpthread $(TRACE_LIBS) $(LIBZSTD_LDLAGS)
+CONFIG_LIBS	= -lrt -lpthread $(TRACE_LIBS) $(ZLIB_LDLAGS) $(LIBZSTD_LDLAGS)
 CONFIG_FLAGS	=
 
-ifeq ($(ZLIB_INSTALLED), 1)
-CONFIG_LIBS += -lz
-endif
-
 all: $(TARGETS)
 
 $(bdir):