diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-08-05 11:40:32 -0400 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-08-05 11:45:10 -0400 |
commit | 762839a848e3725e20300c66a467259ad79e616b (patch) | |
tree | d788efd660ee5bfc64cb2d054d1a4c1304447954 | |
parent | 1504f3f5d8b098b57f11024a9443d918dab9da88 (diff) | |
download | trace-cmd-762839a848e3725e20300c66a467259ad79e616b.tar.gz |
tracecmd: Use make variable instead of if statement for zlib test
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!)
Link: https://lore.kernel.org/linux-trace-devel/20220805154040.2014381-2-rostedt@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | lib/trace-cmd/Makefile | 6 | ||||
-rw-r--r-- | tracecmd/Makefile | 6 |
3 files changed, 5 insertions, 10 deletions
@@ -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 9374b163..a476e35b 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 56be9a3b..8207c54b 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): |