[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 16/21] trace: add infrastructure for building pl
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [RFC PATCH 16/21] trace: add infrastructure for building plugins |
Date: |
Fri, 5 Oct 2018 16:49:05 +0100 |
This allows us to build any bundled plugins in the source tree.
Out-of-tree builds can call Makefile.plugins to build in their own
source tree:
make -f $(QEMU_PATH)/trace/plugins/Makefile.plugins QEMU_SRC=$(QEMU_PATH)
Signed-off-by: Alex Bennée <address@hidden>
---
Makefile | 5 ++++-
trace/Makefile.objs | 24 ++++++++++++++++++++++++
trace/plugins/Makefile.plugins | 32 ++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 1 deletion(-)
create mode 100644 trace/plugins/Makefile.plugins
diff --git a/Makefile b/Makefile
index 1144d6e3ba..e04d1c5124 100644
--- a/Makefile
+++ b/Makefile
@@ -438,7 +438,7 @@ dummy := $(call unnest-vars,, \
include $(SRC_PATH)/tests/Makefile.include
-all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
+all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules plugins
qemu-version.h: FORCE
$(call quiet-command, \
@@ -1091,6 +1091,9 @@ help:
@echo ' all - Build all'
ifdef CONFIG_MODULES
@echo ' modules - Build all modules'
+endif
+ifdef CONFIG_TRACE_PLUGIN
+ @echo ' plugins - Build all plugins'
endif
@echo ' dir/file.o - Build specified target only'
@echo ' install - Install QEMU, documentation and tools'
diff --git a/trace/Makefile.objs b/trace/Makefile.objs
index 4977f654a5..4f62022595 100644
--- a/trace/Makefile.objs
+++ b/trace/Makefile.objs
@@ -58,3 +58,27 @@ util-obj-$(CONFIG_TRACE_PLUGIN) += plugins.o
util-obj-y += control.o
target-obj-y += control-target.o
util-obj-y += qmp.o
+
+######################################################################
+# Plugins
+ifdef CONFIG_TRACE_PLUGIN
+
+PLUGINS=$(dir $(wildcard $(SRC_PATH)/trace/plugins/*/.))
+
+.PHONY: plugins $(PLUGINS)
+
+plugins: $(PLUGINS)
+ $(info built all plugins $(PLUGINS))
+
+$(PLUGINS):
+ $(call quiet-command,
\
+ (cd $@ && $(MAKE) -f $(SRC_PATH)/trace/plugins/Makefile.plugins
\
+ QEMU_SRC=$(SRC_PATH)
\
+ BUILD_DIR=$(BUILD_DIR)/trace/plugins),
\
+ "PLUGIN","in $@")
+
+else
+
+plugins:
+
+endif
diff --git a/trace/plugins/Makefile.plugins b/trace/plugins/Makefile.plugins
new file mode 100644
index 0000000000..0056d91c74
--- /dev/null
+++ b/trace/plugins/Makefile.plugins
@@ -0,0 +1,32 @@
+# -*- Mode: makefile -*-
+#
+# QEMU plugins
+#
+# This Makefile is used to build plugins for QEMU. Unlike the rest of
+# the object files we build we don't have visibility of QEMU's
+# internals. When called from the main makefile we build plugins into
+# BUILD_DIR/plugins otherwise where ever the Makefile was called from.
+# QEMU_SRC
+#
+
+BUILD_DIR ?= $(CURDIR)
+CC ?= cc
+
+ifndef QEMU_SRC
+$(error need to define QEMU_SRC for the build)
+endif
+
+GLIB_CFLAGS = $(shell pkg-config --cflags glib-2.0)
+CFLAGS = -I$(QEMU_SRC)/include/plugins $(GLIB_CFLAGS) -fno-PIE -fPIC -O3 -g
+LDFLAGS = $(shell pkg-config --libs glib-2.0) -shared
+
+SRC = $(wildcard *.c)
+PLUGINS = $(addprefix $(BUILD_DIR)/,$(SRC:.c=.so))
+
+$(BUILD_DIR)/%.so: %.c
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+
+all: $(PLUGINS)
+
+clean:
+ rm -f $(PLUGIN_SO) $(PLUGIN_OBJ)
--
2.17.1
- [Qemu-devel] [RFC PATCH 10/21] qom/cpu: add a cpu_exit trace event, (continued)
- [Qemu-devel] [RFC PATCH 10/21] qom/cpu: add a cpu_exit trace event, Alex Bennée, 2018/10/05
- [Qemu-devel] [RFC PATCH 12/21] configure: expose a plugin to the trace-backends, Alex Bennée, 2018/10/05
- [Qemu-devel] [RFC PATCH 13/21] tracetool: generate plugin snippets, Alex Bennée, 2018/10/05
- [Qemu-devel] [RFC PATCH 09/21] trace: suppress log output of trace points, Alex Bennée, 2018/10/05
- [Qemu-devel] [RFC PATCH 02/21] util/log: add qemu_dfilter_append_range(), Alex Bennée, 2018/10/05
- [Qemu-devel] [RFC PATCH 16/21] trace: add infrastructure for building plugins,
Alex Bennée <=
- [Qemu-devel] [RFC PATCH 11/21] trace: expose a plugin fn pointer in TraceEvent, Alex Bennée, 2018/10/05
- [Qemu-devel] [RFC PATCH 14/21] trace: add support for plugin infrastructure, Alex Bennée, 2018/10/05
- [Qemu-devel] [RFC PATCH 07/21] accel/tcg/cputlb: convert tlb_flush debugging into trace events, Alex Bennée, 2018/10/05