From patchwork Fri Oct 5 15:49:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 148210 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp624018lji; Fri, 5 Oct 2018 09:01:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV60u947p1P5ST2s388zksrRzfbCqJRVlWbZwDRZMeO3cIr8t8sD6fx2LV/+uvd4t1KFFkfrb X-Received: by 2002:aed:29c5:: with SMTP id o63-v6mr9870120qtd.264.1538755289160; Fri, 05 Oct 2018 09:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538755289; cv=none; d=google.com; s=arc-20160816; b=nTMlJAhuAKgKxzQVR+7qXccTToQ0a9W6E9Swa5pp8u9cHus2aGoa2VwLQX13+CV3Eh g4VMRl1mvrYvKh3R5BuhFHydCgLp4yEUv1+BPEaZkqIzT+ZGMep4edTcZivIQonGakiF 1nWR6RE6NEGhUw3Rh2mjUM4KDYfZAUTzLWAWONYgcw8S+PBiLZINoheOj+OV6CPbPV1I 1TMWo5uWlAcm8xar0x+mKq7oS9yGXioh18OOP1xnB7aM2ZtdlLPyhIqMcluFimGD1zP4 B8NrqIfkeZNA9T/wrUiKh1R130HUeiJKBZL0z+WZQH6KnIvFC6WogfSzrI/ZFJe+H9O0 Cn9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=AIO4WUa6ztDdHcOwmnxWnQEeyVjoNHgZKlm7LfAVX7k=; b=QrMIeogFtOpJBkF0FBEOHVX48G5nXsLxgwrjNiEkM8gHxgHX1QjwQkZmFEiJlsk3Um w+XaL8IfWSKQXsYzQMWbCRMxT6aJ0whTCCx1QRZXIQed2TocDeo+wBYlP0kU1GFOZZFB HCRaYuxscw9dmt8RIt3d1fhXg7Bp5JpQhCsM46m0v9LmefX9YeVL4ezz9sstzZEJZwjk 3qiRErcasXwzmR78xOsQKQpNfhHHTMvNkiZ4K0bf9ilc1nGx3paG+Io7I3qvH3mjCKEc 97Xca7L5nZL89jcA0InakUQmpPk0uG7OC2bwMYcMRK5ZMTdXh4gRWG7YFrol4LS9nDR1 dyeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gYYbld+z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 7-v6si112517qkv.273.2018.10.05.09.01.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 09:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gYYbld+z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SXg-0003D5-Gj for patch@linaro.org; Fri, 05 Oct 2018 12:01:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8SMF-0006fN-Fm for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8SM9-0006Fj-TY for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:39 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:40920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8SM9-00068C-El for qemu-devel@nongnu.org; Fri, 05 Oct 2018 11:49:33 -0400 Received: by mail-wm1-x331.google.com with SMTP id z204-v6so2374589wmc.5 for ; Fri, 05 Oct 2018 08:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AIO4WUa6ztDdHcOwmnxWnQEeyVjoNHgZKlm7LfAVX7k=; b=gYYbld+zifSn9K1DBJBuHRTV0klwmLDdhLdOWb7l6Om2bLoghGMGR7VBhSlIByieGi 8hmvX1nCqjZcuBRQMKoZDRNAPzqvwWzLdlFzEiyJw31g/Xo4SyOAJPUUqC6gwOoazJQy gbo4GQKb8vWDildtMAL9wHkgwxCDzS8qANOv0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AIO4WUa6ztDdHcOwmnxWnQEeyVjoNHgZKlm7LfAVX7k=; b=BGAXxzDmjAxUFXEnGgfvqWl7SCflxqlr5b3hQZxmd4EO5FdmhrliDH9Fh5dFDGayp3 DybYCb7WW/4s5/XX3V7ARDSsn/azIAJCMj8ITTQjaHqdgLXcHUEoMIZs3XkQXV2aCt8z cNM46qNdSbSVzmYk4Ug2lArLRLWXz+gDYe9CyX/0D6opwDHtnvTo/D/EaFFCGOscmDcm F+Fmomi24yYStHugMJa6sYldw0GjJVqm2aqexWWCBguV8aJW2ETLOZiew8Pp8naspmhZ mu7aoDbguhFr4aO9e2PlJEBHnPort+H+Mrr2joabY3f6XWh88ozvo4WZB7DbCsXMREyc 4+hg== X-Gm-Message-State: ABuFfohFyxMbMZdsZJRvkcE6AWIz4n9uoIC0p60a5TVyxoB9eygkVshy skBm1iWUq4Pts1j3I/QEmx1QJY0T/zk= X-Received: by 2002:a1c:af07:: with SMTP id y7-v6mr8566978wme.33.1538754567674; Fri, 05 Oct 2018 08:49:27 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u76-v6sm3521928wmd.10.2018.10.05.08.49.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 08:49:22 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 067913E07DB; Fri, 5 Oct 2018 16:49:12 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:49:05 +0100 Message-Id: <20181005154910.3099-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005154910.3099-1-alex.bennee@linaro.org> References: <20181005154910.3099-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [RFC PATCH 16/21] trace: add infrastructure for building plugins X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , cota@braap.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , vilanova@ac.upc.edu, Pavel.Dovgaluk@ispras.ru Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 -- 2.17.1 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)