libtracefs: More Makefile updates to make packaging the library easier
cover libtracefs: More Makefile updates to make packaging the library easier
Steven Rostedt (VMware) (8):
libtracefs: Clean up tracefs.h
libtracefs: Use $(objtree) instead of $(OUTPUT) for ld.so test
libtracefs: Do not hardcode location of libtraceevent
libtracefs: Use $(obj) instead of $(OUTPUT) for libtracefs.pc file
libtracefs: Allow the pkg-config libs and cflags prefix to be overwritten
libtracefs: Remove unneccessary TRACE_LIBS variable
libtracefs: Have only one definition of overriding CFLAGS
libtracefs: Add -rpath to libtracefs.so
----
Makefile | 30 +++++++++++++----------------- include/tracefs.h | 4 ++-- libtracefs.pc.template | 4 ++-- scripts/utils.mk | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-)
PATCH 1/8 libtracefs: Clean up tracefs.h
From: "Steven Rostedt (VMware)" <[email protected]>
Fix a typo, and use <traceevent/event-parse.h> instead of "traceevent/event-parse.h" for the include name.
--- include/tracefs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/tracefs.h +2 -2
@@ -6,8 +6,8 @@#ifndef _TRACE_FS_H#define _TRACE_FS_H +#include <traceevent/event-parse.h> #include <sched.h> -#include "traceevent/event-parse.h" char *tracefs_get_tracing_file (const char *name);void tracefs_put_tracing_file (char *name);
@@ -18,7 +18,7 @@ const char *tracefs_get_tracing_dir(void);/* tracefs_find_tracing_dir must be freed */ char *tracefs_find_tracing_dir (void ); -/* ftarce instances */ +/* ftrace instances */ struct tracefs_instance ;void tracefs_instance_free (struct tracefs_instance *instance);
Signature · 1 line
2.29.2
PATCH 2/8 libtracefs: Use $(objtree) instead of $(OUTPUT) for ld.so test
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Use the variable $(objtree) to build the test program in the O=path directory, as there is no $(OUTPUT) variable defined.
--- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Makefile +3 -3
@@ -224,14 +224,14 @@ ifeq ("$(DESTDIR)", "") define install_ld_config $(LDCONFIG); \ if ! grep "^$(libdir)$$" $(LD_SO_CONF_PATH)/* &> /dev/null ; then \ - $(CC) -o $(OUTPUT)test $(srctree)/test.c -I $(includedir_SQ) \ + $(CC) -o $(objtree)/test $(srctree)/test.c -I $(includedir_SQ) \ -L $(libdir_SQ) -ltracefs &> /dev/null; \ - if ! $(OUTPUT)test &> /dev/null; then \ + if ! $(objtree)/test &> /dev/null; then \ $(call print_install, trace.conf, $(LD_SO_CONF_PATH)) \ echo $(libdir_SQ) >> $(LD_SO_CONF_PATH)/trace.conf; \ $(LDCONFIG); \ fi; \ - $(RM) $(OUTPUT)test; \ + $(RM) $(objtree)/test; \ fi endef else
Signature · 1 line
2.29.2
PATCH 3/8 libtracefs: Do not hardcode location of libtraceevent
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
The Makefile has LIBS = -L$(obj)/lib/traceevent, which can be incorrect and should not be used. Remove it.
--- Makefile | 2 -- 1 file changed, 2 deletions(-)
Makefile +0 -2
@@ -312,8 +312,6 @@ all: $(DEFAULT_TARGET) $(bdir): @mkdir -p $(bdir) -LIBS = -L$(obj)/lib/traceevent -ltraceevent - $(LIBTRACEFS_STATIC): force $(Q)mkdir -p $(bdir) $(Q)$(MAKE) -C $(src)/src $@
Signature · 1 line
2.29.2
PATCH 4/8 libtracefs: Use $(obj) instead of $(OUTPUT) for libtracefs.pc file
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
The location of libtracefs.pc was incorrectly using $(OUTPUT) which does not even exist, where it should have been using $(obj) instead.
Also need to move the variable declarations down below where $(obj) is defined.
--- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Makefile +3 -3
@@ -61,9 +61,6 @@ includedir_SQ = '$(subst ','\'',$(includedir))' pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \ --variable pc_path pkg-config | tr ":" " ")) -PKG_CONFIG_SOURCE_FILE = libtracefs.pc -PKG_CONFIG_FILE := $(addprefix $(OUTPUT),$(PKG_CONFIG_SOURCE_FILE)) - LIBTRACEEVENT_INCLUDES = $(shell $(PKG_CONFIG) --cflags libtraceevent) LIBTRACEEVENT_LIBS = $(shell $(PKG_CONFIG) --libs libtraceevent)
@@ -133,6 +130,9 @@ LIBTRACEFS_SHARED = $(bdir)/libtracefs.so.$(TRACEFS_VERSION) TRACE_LIBS = $(LIBTRACEEVENT_LIBS) +PKG_CONFIG_SOURCE_FILE = libtracefs.pc +PKG_CONFIG_FILE := $(addprefix $(obj)/,$(PKG_CONFIG_SOURCE_FILE)) + export LIBS TRACE_LIBS export LIBTRACEFS_STATIC LIBTRACEFS_SHARED
Signature · 1 line
2.29.2
PATCH 5/8 libtracefs: Allow the pkg-config libs and cflags prefix to be overwritten
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
In case libtracecmd needs to be built in a destination directory where libtracefs will be located, and not on the host machine, it will need a way to override the location of the include and library directories. Facilitate this by having them use the ${prefix} variable.
--- Makefile | 7 ++++--- libtracefs.pc.template | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-)
Makefile +4 -3
@@ -56,7 +56,8 @@ man_dir = $(prefix)/share/man man_dir_SQ = '$(subst ','\'',$(man_dir))' libdir = $(prefix)/$(libdir_relative) libdir_SQ = '$(subst ','\'',$(libdir))' -includedir = $(prefix)/include/tracefs +includedir_relative ?= include/tracefs +includedir = $(prefix)/$(includedir_relative) includedir_SQ = '$(subst ','\'',$(includedir))' pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \ --variable pc_path pkg-config | tr ":" " "))
@@ -193,8 +194,8 @@ define do_make_pkgconfig_file cp -f ${PKG_CONFIG_SOURCE_FILE}.template ${PKG_CONFIG_FILE}; \ sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; \ sed -i "s|LIB_VERSION|${TRACEFS_VERSION}|g" ${PKG_CONFIG_FILE}; \ - sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \ - sed -i "s|HEADER_DIR|$(includedir)|g" ${PKG_CONFIG_FILE}; + sed -i "s|LIB_DIR|${libdir_relative}|g" ${PKG_CONFIG_FILE}; \ + sed -i "s|HEADER_DIR|$(includedir_relative)|g" ${PKG_CONFIG_FILE}; endef BUILD_PREFIX := $(BUILD_OUTPUT)/build_prefix
libtracefs.pc.template +2 -2
@@ -1,6 +1,6 @@ prefix=INSTALL_PREFIX -libdir=LIB_DIR -includedir=HEADER_DIR +libdir=${prefix}/LIB_DIR +includedir=${prefix}/HEADER_DIR Name: libtracefs URL: https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
Signature · 1 line
2.29.2
PATCH 6/8 libtracefs: Remove unneccessary TRACE_LIBS variable
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
The TRACE_LIBS variable in the Makefile is not not used anywhere. Simply have LIBS equal LIBTRACEEVENT_LIBS, and export LIBS instead.
--- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Makefile +3 -3
@@ -129,12 +129,12 @@ export prefix bindir src obj bdir LIBTRACEFS_STATIC = $(bdir)/libtracefs.a LIBTRACEFS_SHARED = $(bdir)/libtracefs.so.$(TRACEFS_VERSION) -TRACE_LIBS = $(LIBTRACEEVENT_LIBS) - PKG_CONFIG_SOURCE_FILE = libtracefs.pc PKG_CONFIG_FILE := $(addprefix $(obj)/,$(PKG_CONFIG_SOURCE_FILE)) -export LIBS TRACE_LIBS +LIBS = $(LIBTRACEEVENT_LIBS) + +export LIBS export LIBTRACEFS_STATIC LIBTRACEFS_SHARED export Q SILENT VERBOSE EXT
Signature · 1 line
2.29.2
PATCH 7/8 libtracefs: Have only one definition of overriding CFLAGS
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
For some reason, there's two places CFLAGS gets overridden. There only needs to be one. Consolidate them.
--- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Makefile +1 -4
@@ -158,11 +158,8 @@ export CUNIT_INSTALLED export CFLAGS export INCLUDES -# Required CFLAGS -override CFLAGS += -D_GNU_SOURCE $(LIBTRACEEVENT_INCLUDES) - # Append required CFLAGS -override CFLAGS += $(INCLUDES) +override CFLAGS += -D_GNU_SOURCE $(LIBTRACEEVENT_INCLUDES) $(INCLUDES) all: all_cmd
Signature · 1 line
2.29.2
PATCH 8/8 libtracefs: Add -rpath to libtracefs.so
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Pass in "-rpath=$ORIGIN" to the linker when building libtracefs.so, such that the path for libtraceevent.so might be found if it is installed in the same location as libtracefs.
--- scripts/utils.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/utils.mk +1 -1
@@ -56,7 +56,7 @@ do_build_static_lib = \ do_compile_shared_library = \ ($(print_shared_lib_compile) \ - $(CC) --shared $^ -Wl,-soname,$(@F) -o $@ $(LIBS)) + $(CC) --shared $^ '-Wl,-soname,$(@F),-rpath=$$ORIGIN' -o $@ $(LIBS)) do_compile_plugin_obj = \ ($(print_plugin_obj_compile) \
Signature · 1 line
2.29.2