public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: acme@ghostprotocols.net, linux-kernel@vger.kernel.org
Cc: David Ahern <dsahern@gmail.com>, Borislav Petkov <bp@alien8.de>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 03/23] perf: make python support based on CONFIG_LIBPYTHON
Date: Mon,  1 Apr 2013 21:54:17 -0600	[thread overview]
Message-ID: <1364874877-5618-4-git-send-email-dsahern@gmail.com> (raw)
In-Reply-To: <1364874877-5618-1-git-send-email-dsahern@gmail.com>

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
---
 tools/perf/Makefile                     |  105 +++++++++++++++----------------
 tools/perf/Pconfig                      |    3 +
 tools/perf/builtin-script.c             |    2 +-
 tools/perf/config/feature-tests.mak     |    2 +-
 tools/perf/util/trace-event-scripting.c |   17 +++--
 5 files changed, 61 insertions(+), 68 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index af7b746..2225c3d 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -16,8 +16,6 @@ include config/utilities.mak
 #
 # Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
 #
-# Define NO_LIBPYTHON to disable python script extension.
-#
 # Define PYTHON to point to the python binary if the default
 # `python' is not correct; for example: PYTHON=python2
 #
@@ -733,69 +731,64 @@ ifdef CONFIG_LIBPERL
     LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
 endif
 
-disable-python = $(eval $(disable-python_code))
-define disable-python_code
-  BASIC_CFLAGS += -DNO_LIBPYTHON
-  $(if $(1),$(warning No $(1) was found))
-  $(warning Python support will not be built)
-endef
+ifdef CONFIG_LIBPYTHON
+    override PYTHON := \
+        $(call get-executable-or-default,PYTHON,python)
 
-override PYTHON := \
-  $(call get-executable-or-default,PYTHON,python)
+    ifndef PYTHON
+        $(error python interpreter not found. Install it or unset CONFIG_LIBPYTHON to continue.)
+    endif
 
-ifndef PYTHON
-  $(call disable-python,python interpreter)
-else
+    PYTHON_WORD := $(call shell-wordify,$(PYTHON))
 
-  PYTHON_WORD := $(call shell-wordify,$(PYTHON))
+    # python extension build directories
+    PYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/
+    PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
+    PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
+    export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
 
-  ifdef NO_LIBPYTHON
-    $(call disable-python)
-  else
+    python-clean := rm -rf $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
 
     override PYTHON_CONFIG := \
-      $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+        $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
 
     ifndef PYTHON_CONFIG
-      $(call disable-python,python-config tool)
-    else
-
-      PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
-
-      PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
-      PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
-      PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
-      PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
-      FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
-
-      ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y)
-        $(call disable-python,Python.h (for Python 2.x))
-      else
-
-        ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y)
-          $(warning Python 3 is not yet supported; please set)
-          $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
-          $(warning If you also have Python 2 installed, then)
-          $(warning try something like:)
-          $(warning $(and ,))
-          $(warning $(and ,)  make PYTHON=python2)
-          $(warning $(and ,))
-          $(warning Otherwise, disable Python support entirely:)
-          $(warning $(and ,))
-          $(warning $(and ,)  make NO_LIBPYTHON=1)
-          $(warning $(and ,))
-          $(error   $(and ,))
-        else
-          ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
-          EXTLIBS += $(PYTHON_EMBED_LIBADD)
-          LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
-          LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
-          LANG_BINDINGS += $(OUTPUT)python/perf.so
-        endif
-
-      endif
+        $(error python-config not found. Install it or unset CONFIG_LIBPYTHON to continue.)
     endif
-  endif
+
+    PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
+
+    PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
+    PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
+    PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
+    PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
+    FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
+
+    ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
+        $(warning Failed to detect python development kit.)
+        $(warning Install it or unset CONFIG_LIBPYTHON to continue.)
+        $(warning e.g., apt-get install python-dev (ubuntu).)
+        $(warning       yum install python-devel (Fedora).)
+        $(error )
+    endif
+
+    ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y)
+        $(warning Python 3 is not yet supported; please set)
+        $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
+        $(warning If you also have Python 2 installed, then)
+        $(warning try something like:)
+        $(warning $(and ,))
+        $(warning $(and ,)  make PYTHON=python2)
+        $(warning $(and ,))
+        $(warning Otherwise, disable Python support entirely by unsetting CONFIG_LIBPYTHON.)
+        $(error   $(and ,))
+    endif
+
+    ALL_LDFLAGS   += $(PYTHON_EMBED_LDFLAGS)
+    EXTLIBS       += $(PYTHON_EMBED_LIBADD)
+    LIB_OBJS      += $(OUTPUT)util/scripting-engines/trace-event-python.o
+    LIB_OBJS      += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
+    LANG_BINDINGS += $(OUTPUT)python/perf.so
 endif
 
 ifdef NO_DEMANGLE
diff --git a/tools/perf/Pconfig b/tools/perf/Pconfig
index a636af3..67ae110 100644
--- a/tools/perf/Pconfig
+++ b/tools/perf/Pconfig
@@ -1,2 +1,5 @@
 config LIBPERL
     bool "Enable support for perl scripting engine"
+
+config LIBPYTHON
+    bool "Enable support for python scripting engine"
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 7841533..e57b87d 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1115,7 +1115,7 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
 		if (strstr(lang_path, "perl"))
 			continue;
 #endif
-#ifdef NO_LIBPYTHON
+#ifndef CONFIG_LIBPYTHON
 		if (strstr(lang_path, "python"))
 			continue;
 #endif
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak
index 1222b33..2a2fa3b 100644
--- a/tools/perf/config/feature-tests.mak
+++ b/tools/perf/config/feature-tests.mak
@@ -115,7 +115,7 @@ return 0;
 endef
 endif
 
-ifndef NO_LIBPYTHON
+ifdef CONFIG_LIBPYTHON
 define SOURCE_PYTHON_VERSION
 #include <Python.h>
 #if PY_VERSION_HEX >= 0x03000000
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index 3343d97..932d480 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -46,11 +46,8 @@ static void process_event_unsupported(union perf_event *event __maybe_unused,
 
 static void print_python_unsupported_msg(void)
 {
-	fprintf(stderr, "Python scripting not supported."
-		"  Install libpython and rebuild perf to enable it.\n"
-		"For example:\n  # apt-get install python-dev (ubuntu)"
-		"\n  # yum install python-devel (Fedora)"
-		"\n  etc.\n");
+	fprintf(stderr, "Python scripting not supported.\n"
+		"Enable CONFIG_LIBPYTHON and rebuild perf to enable it.\n");
 }
 
 static int python_start_script_unsupported(const char *script __maybe_unused,
@@ -94,17 +91,17 @@ static void register_python_scripting(struct scripting_ops *scripting_ops)
 	scripting_context = malloc(sizeof(struct scripting_context));
 }
 
-#ifdef NO_LIBPYTHON
+#ifdef CONFIG_LIBPYTHON
+extern struct scripting_ops python_scripting_ops;
+
 void setup_python_scripting(void)
 {
-	register_python_scripting(&python_scripting_unsupported_ops);
+	register_python_scripting(&python_scripting_ops);
 }
 #else
-extern struct scripting_ops python_scripting_ops;
-
 void setup_python_scripting(void)
 {
-	register_python_scripting(&python_scripting_ops);
+	register_python_scripting(&python_scripting_unsupported_ops);
 }
 #endif
 
-- 
1.7.10.1


  parent reply	other threads:[~2013-04-02  3:54 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-02  3:54 [PATCH 00/23] perf: integrate with kconfig and CONFIG driven features David Ahern
2013-04-02  3:54 ` [PATCH 01/23] perf: initial infrasructure for kconfig David Ahern
2013-04-02  8:22   ` Paul Bolle
2013-04-02 15:09     ` David Ahern
2013-04-02  3:54 ` [PATCH 02/23] perf: make perl support based on CONFIG_LIBPERL David Ahern
2013-04-02  3:54 ` David Ahern [this message]
2013-04-02  3:54 ` [PATCH 04/23] perf: make gtk2 support based on CONFIG_GTK2 David Ahern
2013-04-02  3:54 ` [PATCH 05/23] perf: make newt support based on CONFIG_NEWT David Ahern
2013-04-02  3:54 ` [PATCH 06/23] perf: remove NEWT_SUPPORT in favor of CONFIG_NEWT David Ahern
2013-04-02  3:54 ` [PATCH 07/23] perf: remove GTK2_SUPPORT in favor of CONFIG_GTK2 David Ahern
2013-04-02  3:54 ` [PATCH 08/23] perf: make elf support based on CONFIG_LIBELF David Ahern
2013-04-02  3:54 ` [PATCH 09/23] perf: make cfi unwind support based on CONFIG_LIBUNWIND David Ahern
2013-04-02  9:32   ` Paul Bolle
2013-04-02 15:20     ` David Ahern
2013-04-04  8:02       ` Paul Bolle
2013-04-02  3:54 ` [PATCH 10/23] perf: make demangle support based on CONFIG_DEMANGLE David Ahern
2013-04-02  9:26   ` Paul Bolle
2013-04-02  3:54 ` [PATCH 11/23] perf: make dwarf support based on CONFIG_DWARF David Ahern
2013-04-02  3:54 ` [PATCH 12/23] perf: add BIONIC config option David Ahern
2013-04-02  3:54 ` [PATCH 13/23] perf: make numa support based on CONFIG_LIBNUMA David Ahern
2013-04-02  3:54 ` [PATCH 14/23] perf: make backtrace support based on CONFIG_BACKTRACE David Ahern
2013-04-02  3:54 ` [PATCH 15/23] perf: make libaudit support based on CONFIG_LIBAUDIT David Ahern
2013-04-02  3:54 ` [PATCH 16/23] perf: consolidate CONFIG_LIBUNWIND checks in Makefile David Ahern
2013-04-02  3:54 ` [PATCH 17/23] perf: remove LIBUNWIND_SUPPORT in favor of CONFIG_LIBUNWIND David Ahern
2013-04-02  3:54 ` [PATCH 18/23] perf: deprecate LIBELF_SUPPORT in favor of CONFIG_LIBELF David Ahern
2013-04-02  3:54 ` [PATCH 19/23] perf: deprecate DWARF_SUPPORT in favor of CONFIG_DWARF David Ahern
2013-04-02  3:54 ` [PATCH 20/23] perf: consolidate CONFIG_LIBELF checks in Makefile David Ahern
2013-04-02  9:37   ` Paul Bolle
2013-04-02 15:21     ` David Ahern
2013-04-02  3:54 ` [PATCH 21/23] perf: consolidate CONFIG_DWARF " David Ahern
2013-04-02  3:54 ` [PATCH 22/23] perf: only add elf to EXTLIBS if CONFIG_LIBELF is set David Ahern
2013-04-02  3:54 ` [PATCH 23/23] perf: only add elf-based object files " David Ahern
     [not found] <1364874809-5575-1-git-send-email-dsahern@gmail.com>
2013-04-02  3:53 ` [PATCH 03/23] perf: make python support based on CONFIG_LIBPYTHON David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364874877-5618-4-git-send-email-dsahern@gmail.com \
    --to=dsahern@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=bp@alien8.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox