libtracefs: Clean up of the source directory
cover libtracefs: Clean up of the source directory
Steven Rostedt (VMware) (6):
libtracefs: Move features.mk into scripts directory
libtracefs: Remove LIBTRACEFS_DIR as it is the same as bdir
libtracefs: Use LIBTRACEFS_STATIC/SHARED instead of open coding them
libtracefs: Move source files to new src/ directory
libtracefs: Use pkg-config to find libtraceevent
libtracefs: Have make clean remove the .so.X file
----
Makefile | 54 +++++++++++----------------- features.mk => scripts/features.mk | 0 tracefs-events.c => src/tracefs-events.c | 0 tracefs-instance.c => src/tracefs-instance.c | 0 tracefs-utils.c => src/tracefs-utils.c | 0 utest/Makefile | 2 +- 6 files changed, 22 insertions(+), 34 deletions(-) rename features.mk => scripts/features.mk (100%) rename tracefs-events.c => src/tracefs-events.c (100%) rename tracefs-instance.c => src/tracefs-instance.c (100%) rename tracefs-utils.c => src/tracefs-utils.c (100%)
PATCH 1/6 libtracefs: Move features.mk into scripts directory
From: "Steven Rostedt (VMware)" <[email protected]>
In order to clean up the directory structure, move the features.mk into the scripts directory. That's where the helper files for the Makefile should live anyway.
--- Makefile | 2 +- features.mk => scripts/features.mk | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename features.mk => scripts/features.mk (100%)
Makefile +1 -1
@@ -142,7 +142,7 @@ include scripts/utils.mk INCLUDES = -I$(src)/include INCLUDES += -I$(src)/include/tracefs -include $(src)/features.mk +include $(src)/scripts/features.mk # Set compile option CFLAGS if not set elsewhere CFLAGS ?= -g -Wall
scripts/features.mk renamed from features.mk +0 -0
Signature · 1 line
2.28.0
PATCH 2/6 libtracefs: Remove LIBTRACEFS_DIR as it is the same as bdir
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Remove the variable LIBTRACEFS_DIR as it is simply bdir, and makes the Makefile confusing. Simply use $(bdir) where $(LIBTRACEFS_DIR) is currently used.
--- Makefile | 11 +++++------ utest/Makefile | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-)
Makefile +5 -6
@@ -123,16 +123,15 @@ src := $(srctree) obj := $(objtree) bdir := $(obj)/lib/tracefs -export prefix bindir src obj +export prefix bindir src obj bdir -LIBTRACEFS_DIR = $(obj)/lib/tracefs -LIBTRACEFS_STATIC = $(LIBTRACEFS_DIR)/libtracefs.a -LIBTRACEFS_SHARED = $(LIBTRACEFS_DIR)/libtracefs.so.$(TRACEFS_VERSION) +LIBTRACEFS_STATIC = $(bdir)/libtracefs.a +LIBTRACEFS_SHARED = $(bdir)/libtracefs.so.$(TRACEFS_VERSION) -TRACE_LIBS = -L$(LIBTRACEFS_DIR) -ltracefs +TRACE_LIBS = -L$(bdir) -ltracefs export LIBS TRACE_LIBS -export LIBTRACEFS_STATIC LIBTRACEFS_SHARED LIBTRACEFS_DIR +export LIBTRACEFS_STATIC LIBTRACEFS_SHARED export Q SILENT VERBOSE EXT
utest/Makefile +1 -1
@@ -11,7 +11,7 @@ OBJS += tracefs-utest.o LIBS += -lcunit \ -ldl \ - -L$(LIBTRACEFS_DIR) -ltracefs + -L$(bdir) -ltracefs OBJS := $(OBJS:%.o=$(bdir)/%.o) DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d)
Signature · 1 line
2.28.0
PATCH 3/6 libtracefs: Use LIBTRACEFS_STATIC/SHARED instead of open coding them
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
The macros LIBTRACEFS_STATIC is defined as $(bdir)/libtracefs.a and LIBTRACEFS_SHARED is defined as $(bdir)/libtracefs.so.$(TRACE_VERSION). Instead of open coding them elsewhere in the file, simply use the defined macros.
--- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Makefile +3 -3
@@ -252,7 +252,7 @@ force: # information in a variable so we can use it in if_changed and friends. .PHONY: $(PHONY) -DEFAULT_TARGET = $(bdir)/libtracefs.a +DEFAULT_TARGET = $(LIBTRACEFS_STATIC) OBJS = OBJS += tracefs-utils.o
@@ -272,10 +272,10 @@ $(DEPS): | $(bdir) LIBS = -L$(obj)/lib/traceevent -ltraceevent -$(bdir)/libtracefs.a: $(OBJS) +$(LIBTRACEFS_STATIC): $(OBJS) $(Q)$(call do_build_static_lib) -$(bdir)/libtracefs.so.$(TRACEFS_VERSION): $(OBJS) +$(LIBTRACEFS_SHARED): $(OBJS) $(Q)$(call do_compile_shared_library) @ln -sf $(@F) $(bdir)/libtracefs.so @ln -sf $(@F) $(bdir)/libtracefs.so.$(TFS_VERSION)
Signature · 1 line
2.28.0
PATCH 4/6 libtracefs: Move source files to new src/ directory
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
In cleaning up the directory structure, move the C files into their own "src/" directory.
--- Makefile | 28 ++++---------------- tracefs-events.c => src/tracefs-events.c | 0 tracefs-instance.c => src/tracefs-instance.c | 0 tracefs-utils.c => src/tracefs-utils.c | 0 4 files changed, 5 insertions(+), 23 deletions(-) rename tracefs-events.c => src/tracefs-events.c (100%) rename tracefs-instance.c => src/tracefs-instance.c (100%) rename tracefs-utils.c => src/tracefs-utils.c (100%)
Makefile +5 -23
@@ -267,35 +267,17 @@ all: $(DEFAULT_TARGET) $(bdir): @mkdir -p $(bdir) -$(OBJS): | $(bdir) -$(DEPS): | $(bdir) - LIBS = -L$(obj)/lib/traceevent -ltraceevent -$(LIBTRACEFS_STATIC): $(OBJS) - $(Q)$(call do_build_static_lib) - -$(LIBTRACEFS_SHARED): $(OBJS) - $(Q)$(call do_compile_shared_library) - @ln -sf $(@F) $(bdir)/libtracefs.so - @ln -sf $(@F) $(bdir)/libtracefs.so.$(TFS_VERSION) - -$(bdir)/%.o: %.c - $(Q)$(call do_fpic_compile) - -$(DEPS): $(bdir)/.%.d: %.c - $(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@ +$(LIBTRACEFS_STATIC): force + $(Q)$(MAKE) -C $(src)/src $@ -$(OBJS): $(bdir)/%.o : $(bdir)/.%.d - -dep_includes := $(wildcard $(DEPS)) - -ifneq ($(dep_includes),) - include $(dep_includes) -endif +$(bdir)/libtracefs.so.$(TRACEFS_VERSION): force + $(Q)$(MAKE) -C $(src)/src $@ clean: $(MAKE) -C $(src)/utest clean + $(MAKE) -C $(src)/src clean $(RM) $(TARGETS) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(RM) $(PKG_CONFIG_FILE)
src/tracefs-events.c renamed from tracefs-events.c +0 -0
src/tracefs-instance.c renamed from tracefs-instance.c +0 -0
src/tracefs-utils.c renamed from tracefs-utils.c +0 -0
Signature · 1 line
2.28.0
PATCH 5/6 libtracefs: Use pkg-config to find libtraceevent
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
As libtracefs is dependent on libtraceevent, use the proper pkg-config method to find where libtraceevent is installed.
--- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
Makefile +9 -2
@@ -62,6 +62,13 @@ pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \ 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) + +ifeq ("$(LIBTRACEEVENT_INCLUDES)","") +$(error libtraceevent.so not installed) +endif + ifeq ($(prefix),/usr/local) etcdir ?= /etc else
@@ -128,7 +135,7 @@ export prefix bindir src obj bdir LIBTRACEFS_STATIC = $(bdir)/libtracefs.a LIBTRACEFS_SHARED = $(bdir)/libtracefs.so.$(TRACEFS_VERSION) -TRACE_LIBS = -L$(bdir) -ltracefs +TRACE_LIBS = $(LIBTRACEEVENT_LIBS) export LIBS TRACE_LIBS export LIBTRACEFS_STATIC LIBTRACEFS_SHARED
@@ -155,7 +162,7 @@ export CFLAGS export INCLUDES # Required CFLAGS -override CFLAGS += -D_GNU_SOURCE +override CFLAGS += -D_GNU_SOURCE $(LIBTRACEEVENT_INCLUDES) # Append required CFLAGS override CFLAGS += $(INCLUDES)
Signature · 1 line
2.28.0
PATCH 6/6 libtracefs: Have make clean remove the .so.X file
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
"make clean" was leaving behind libtracefs.so.0, in the lib/tracefs directory. Add $(bdir)/*.so.* to the remove line to catch these files as well.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -285,7 +285,7 @@ $(bdir)/libtracefs.so.$(TRACEFS_VERSION): force clean: $(MAKE) -C $(src)/utest clean $(MAKE) -C $(src)/src clean - $(RM) $(TARGETS) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d + $(RM) $(TARGETS) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.so.* $(bdir)/*.o $(bdir)/.*.d $(RM) $(PKG_CONFIG_FILE) .PHONY: clean
Signature · 1 line
2.28.0
Quoted 9 lines · Steven Rostedt
Steven Rostedt (VMware) (6):
libtracefs: Move features.mk into scripts directory
libtracefs: RemoveLIBTRACEFS_DIRas it is the same as bdir
libtracefs: Use LIBTRACEFS_STATIC/SHARED instead of open coding them
libtracefs: Move source files to new src/ directory
libtracefs: Use pkg-config to find libtraceevent
libtracefs: Have make clean remove the .so.X file
The changes look good to me.
Quoted 12 lines
----
Makefile | 54 +++++++++++----------------- features.mk => scripts/features.mk | 0 tracefs-events.c => src/tracefs-events.c | 0 tracefs-instance.c => src/tracefs-instance.c | 0 tracefs-utils.c => src/tracefs-utils.c | 0 utest/Makefile | 2 +- 6 files changed, 22 insertions(+), 34 deletions(-) rename features.mk => scripts/features.mk (100%) rename tracefs-events.c => src/tracefs-events.c (100%) rename tracefs-instance.c => src/tracefs-instance.c (100%) rename tracefs-utils.c => src/tracefs-utils.c (100%)
Signature · 2 lines
Tzvetomir (Ceco) Stoyanov VMware Open Source Technology Center