diff mbox series

[v2,13/15] libtracefs: Build in the same directories as the source

Message ID 20211217055041.19559-14-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit fe21539dc8467c672ad827d96ad05435f442328c
Headers show
Series libtracefs: Updates to the Makefile | expand

Commit Message

Steven Rostedt Dec. 17, 2021, 5:50 a.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Modify the descend macro to create the same directory as the source is in
and build the objects in that directory.

Sort out the "lib" directory to only have the libraries built in that
directory.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile         | 18 ++++++++++--------
 scripts/utils.mk |  3 ++-
 src/Makefile     |  3 ---
 3 files changed, 12 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index bf085bfdb800..6e18e0a015f5 100644
--- a/Makefile
+++ b/Makefile
@@ -119,13 +119,16 @@  srctree		:= $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR))
 objtree		:= $(BUILD_OUTPUT)
 src		:= $(srctree)
 obj		:= $(objtree)
-bdir		:= $(obj)/lib/tracefs
+bdir		:= $(obj)/lib
 
 export prefix src obj bdir
 
 LIBTRACEFS_STATIC = $(bdir)/libtracefs.a
 LIBTRACEFS_SHARED = $(bdir)/libtracefs.so.$(TRACEFS_VERSION)
 
+LIBTRACEFS_SHARED_SO = $(bdir)/libtracefs.so
+LIBTRACEFS_SHARED_VERSION = $(bdir)/libtracefs.so.$(TFS_VERSION)
+
 PKG_CONFIG_SOURCE_FILE = libtracefs.pc
 PKG_CONFIG_FILE := $(addprefix $(obj)/,$(PKG_CONFIG_SOURCE_FILE))
 
@@ -134,6 +137,7 @@  LIBS = $(LIBTRACEEVENT_LIBS) -lpthread
 export LIBS
 export LIBTRACEFS_STATIC LIBTRACEFS_SHARED
 export LIBTRACEEVENT_LIBS LIBTRACEEVENT_INCLUDES
+export LIBTRACEFS_SHARED_SO LIBTRACEFS_SHARED_VERSION
 
 export Q SILENT VERBOSE EXT
 
@@ -165,12 +169,12 @@  LIB_TARGET  = libtracefs.a libtracefs.so.$(TRACEFS_VERSION)
 LIB_INSTALL = libtracefs.a libtracefs.so*
 LIB_INSTALL := $(addprefix $(bdir)/,$(LIB_INSTALL))
 
-TARGETS = $(LIBTRACEFS_SHARED) $(LIBTRACEFS_STATIC)
+TARGETS = libtracefs.so libtracefs.a
 
 all_cmd: $(TARGETS) $(PKG_CONFIG_FILE)
 
-libtracefs.a: $(LIBTRACEFS_STATIC)
-libtracefs.so: $(LIBTRACEFS_SHARED)
+libtracefs.a: $(bdir) $(LIBTRACEFS_STATIC)
+libtracefs.so: $(bdir) $(LIBTRACEFS_SHARED)
 
 libs: libtracefs.a libtracefs.so
 
@@ -357,19 +361,17 @@  $(VERSION_FILE): force
 	$(Q)$(call update_version.h)
 
 $(LIBTRACEFS_STATIC): force
-	$(Q)mkdir -p $(bdir)
 	$(Q)$(call descend,$(src)/src,$@)
 
 $(bdir)/libtracefs.so.$(TRACEFS_VERSION): force
-	$(Q)mkdir -p $(bdir)
 	$(Q)$(call descend,$(src)/src,libtracefs.so)
 
-samples/sqlhist: $(LIBTRACEFS_STATIC)
+samples/sqlhist: libtracefs.a
 	$(Q)$(call descend,$(src)/samples,sqlhist)
 
 sqlhist: samples/sqlhist
 
-samples: $(LIBTRACEFS_STATIC) force
+samples: libtracefs.a force
 	$(Q)$(call descend,$(src)/samples,all)
 
 clean:
diff --git a/scripts/utils.mk b/scripts/utils.mk
index 0f6225d3ee68..3bf59c550b1d 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -120,7 +120,8 @@  endif
 #
 descend = \
 	($(print_descend)		\
-	$(MAKE) $(PRINT_DIR) -C $(1) $(2))
+	mkdir -p $(obj)/$(BASE1); \
+	$(MAKE) $(PRINT_DIR) bdir=$(obj)/$(BASE1) -C $(1) $(2))
 
 
 define make_version.h
diff --git a/src/Makefile b/src/Makefile
index f284c70a640a..985744ba1118 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -22,9 +22,6 @@  OBJS += tracefs-sqlhist.o
 OBJS := $(OBJS:%.o=$(bdir)/%.o)
 DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d)
 
-LIBTRACEFS_SHARED_SO = $(bdir)/libtracefs.so
-LIBTRACEFS_SHARED_VERSION = $(bdir)/libtracefs.so.$(TFS_VERSION)
-
 $(LIBTRACEFS_STATIC): $(OBJS)
 	$(Q)$(call do_build_static_lib)