lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1458767880-3288-3-git-send-email-acme@kernel.org>
Date:	Wed, 23 Mar 2016 18:17:39 -0300
From:	Arnaldo Carvalho de Melo <acme@...nel.org>
To:	Ingo Molnar <mingo@...nel.org>
Cc:	linux-kernel@...r.kernel.org,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Josh Poimboeuf <jpoimboe@...hat.com>,
	Namhyung Kim <namhyung@...nel.org>,
	Wang Nan <wangnan0@...wei.com>
Subject: [PATCH 02/23] tools: Move utilities.mak from perf to tools/scripts/

From: Arnaldo Carvalho de Melo <acme@...hat.com>

As it is used by several other tools, better move it outside tools/perf.

Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Wang Nan <wangnan0@...wei.com>
Link: http://lkml.kernel.org/n/tip-34s9kue3xq9w5mijdmfrfx8s@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/lib/api/Makefile            |   2 +-
 tools/lib/subcmd/Makefile         |   2 +-
 tools/perf/Documentation/Makefile |   2 +-
 tools/perf/Makefile.perf          |   2 +-
 tools/perf/config/Makefile        |   2 +-
 tools/perf/config/utilities.mak   | 179 --------------------------------------
 tools/scripts/utilities.mak       | 179 ++++++++++++++++++++++++++++++++++++++
 7 files changed, 184 insertions(+), 184 deletions(-)
 delete mode 100644 tools/perf/config/utilities.mak
 create mode 100644 tools/scripts/utilities.mak

diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile
index bbc82c614bee..316f308a63ea 100644
--- a/tools/lib/api/Makefile
+++ b/tools/lib/api/Makefile
@@ -1,5 +1,5 @@
 include ../../scripts/Makefile.include
-include ../../perf/config/utilities.mak		# QUIET_CLEAN
+include ../../scripts/utilities.mak		# QUIET_CLEAN
 
 ifeq ($(srctree),)
 srctree := $(patsubst %/,%,$(dir $(shell pwd)))
diff --git a/tools/lib/subcmd/Makefile b/tools/lib/subcmd/Makefile
index 629cf8c14e68..25b3f69f4364 100644
--- a/tools/lib/subcmd/Makefile
+++ b/tools/lib/subcmd/Makefile
@@ -1,5 +1,5 @@
 include ../../scripts/Makefile.include
-include ../../perf/config/utilities.mak		# QUIET_CLEAN
+include ../../scripts/utilities.mak		# QUIET_CLEAN
 
 ifeq ($(srctree),)
 srctree := $(patsubst %/,%,$(dir $(shell pwd)))
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile
index 3ba1c0b09908..098cfb9ca8f0 100644
--- a/tools/perf/Documentation/Makefile
+++ b/tools/perf/Documentation/Makefile
@@ -1,5 +1,5 @@
 include ../../scripts/Makefile.include
-include ../config/utilities.mak
+include ../../scripts/utilities.mak
 
 MAN1_TXT= \
 	$(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 4a4fad4182f5..000ea210389d 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -3,7 +3,7 @@ include ../scripts/Makefile.include
 # The default target of this Makefile is...
 all:
 
-include config/utilities.mak
+include ../scripts/utilities.mak
 
 # Define V to have a more verbose compile.
 #
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index eca6a912e8c2..f7d7f5a1cad5 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -109,7 +109,7 @@ ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
   CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
 endif
 
-include $(src-perf)/config/utilities.mak
+include $(srctree)/tools/scripts/utilities.mak
 
 ifeq ($(call get-executable,$(FLEX)),)
   dummy := $(error Error: $(FLEX) is missing on this system, please install it)
diff --git a/tools/perf/config/utilities.mak b/tools/perf/config/utilities.mak
deleted file mode 100644
index c16ce833079c..000000000000
--- a/tools/perf/config/utilities.mak
+++ /dev/null
@@ -1,179 +0,0 @@
-# This allows us to work with the newline character:
-define newline
-
-
-endef
-newline := $(newline)
-
-# nl-escape
-#
-# Usage: escape = $(call nl-escape[,escape])
-#
-# This is used as the common way to specify
-# what should replace a newline when escaping
-# newlines; the default is a bizarre string.
-#
-nl-escape = $(if $(1),$(1),m822df3020w6a44id34bt574ctac44eb9f4n)
-
-# escape-nl
-#
-# Usage: escaped-text = $(call escape-nl,text[,escape])
-#
-# GNU make's $(shell ...) function converts to a
-# single space each newline character in the output
-# produced during the expansion; this may not be
-# desirable.
-#
-# The only solution is to change each newline into
-# something that won't be converted, so that the
-# information can be recovered later with
-# $(call unescape-nl...)
-#
-escape-nl = $(subst $(newline),$(call nl-escape,$(2)),$(1))
-
-# unescape-nl
-#
-# Usage: text = $(call unescape-nl,escaped-text[,escape])
-#
-# See escape-nl.
-#
-unescape-nl = $(subst $(call nl-escape,$(2)),$(newline),$(1))
-
-# shell-escape-nl
-#
-# Usage: $(shell some-command | $(call shell-escape-nl[,escape]))
-#
-# Use this to escape newlines from within a shell call;
-# the default escape is a bizarre string.
-#
-# NOTE: The escape is used directly as a string constant
-#       in an `awk' program that is delimited by shell
-#       single-quotes, so be wary of the characters
-#       that are chosen.
-#
-define shell-escape-nl
-awk 'NR==1 {t=$$0} NR>1 {t=t "$(nl-escape)" $$0} END {printf t}'
-endef
-
-# shell-unescape-nl
-#
-# Usage: $(shell some-command | $(call shell-unescape-nl[,escape]))
-#
-# Use this to unescape newlines from within a shell call;
-# the default escape is a bizarre string.
-#
-# NOTE: The escape is used directly as an extended regular
-#       expression constant in an `awk' program that is
-#       delimited by shell single-quotes, so be wary
-#       of the characters that are chosen.
-#
-# (The bash shell has a bug where `{gsub(...),...}' is
-#  misinterpreted as a brace expansion; this can be
-#  overcome by putting a space between `{' and `gsub').
-#
-define shell-unescape-nl
-awk 'NR==1 {t=$$0} NR>1 {t=t "\n" $$0} END { gsub(/$(nl-escape)/,"\n",t); printf t }'
-endef
-
-# escape-for-shell-sq
-#
-# Usage: embeddable-text = $(call escape-for-shell-sq,text)
-#
-# This function produces text that is suitable for
-# embedding in a shell string that is delimited by
-# single-quotes.
-#
-escape-for-shell-sq =  $(subst ','\'',$(1))
-
-# shell-sq
-#
-# Usage: single-quoted-and-escaped-text = $(call shell-sq,text)
-#
-shell-sq = '$(escape-for-shell-sq)'
-
-# shell-wordify
-#
-# Usage: wordified-text = $(call shell-wordify,text)
-#
-# For instance:
-#
-#  |define text
-#  |hello
-#  |world
-#  |endef
-#  |
-#  |target:
-#  |	echo $(call shell-wordify,$(text))
-#
-# At least GNU make gets confused by expanding a newline
-# within the context of a command line of a makefile rule
-# (this is in constrast to a `$(shell ...)' function call,
-# which can handle it just fine).
-#
-# This function avoids the problem by producing a string
-# that works as a shell word, regardless of whether or
-# not it contains a newline.
-#
-# If the text to be wordified contains a newline, then
-# an intrictate shell command substitution is constructed
-# to render the text as a single line; when the shell
-# processes the resulting escaped text, it transforms
-# it into the original unescaped text.
-#
-# If the text does not contain a newline, then this function
-# produces the same results as the `$(shell-sq)' function.
-#
-shell-wordify = $(if $(findstring $(newline),$(1)),$(_sw-esc-nl),$(shell-sq))
-define _sw-esc-nl
-"$$(echo $(call escape-nl,$(shell-sq),$(2)) | $(call shell-unescape-nl,$(2)))"
-endef
-
-# is-absolute
-#
-# Usage: bool-value = $(call is-absolute,path)
-#
-is-absolute = $(shell echo $(shell-sq) | grep -q ^/ && echo y)
-
-# lookup
-#
-# Usage: absolute-executable-path-or-empty = $(call lookup,path)
-#
-# (It's necessary to use `sh -c' because GNU make messes up by
-#  trying too hard and getting things wrong).
-#
-lookup = $(call unescape-nl,$(shell sh -c $(_l-sh)))
-_l-sh = $(call shell-sq,command -v $(shell-sq) | $(call shell-escape-nl,))
-
-# is-executable
-#
-# Usage: bool-value = $(call is-executable,path)
-#
-# (It's necessary to use `sh -c' because GNU make messes up by
-#  trying too hard and getting things wrong).
-#
-is-executable = $(call _is-executable-helper,$(shell-sq))
-_is-executable-helper = $(shell sh -c $(_is-executable-sh))
-_is-executable-sh = $(call shell-sq,test -f $(1) -a -x $(1) && echo y)
-
-# get-executable
-#
-# Usage: absolute-executable-path-or-empty = $(call get-executable,path)
-#
-# The goal is to get an absolute path for an executable;
-# the `command -v' is defined by POSIX, but it's not
-# necessarily very portable, so it's only used if
-# relative path resolution is requested, as determined
-# by the presence of a leading `/'.
-#
-get-executable = $(if $(1),$(if $(is-absolute),$(_ge-abspath),$(lookup)))
-_ge-abspath = $(if $(is-executable),$(1))
-
-# get-supplied-or-default-executable
-#
-# Usage: absolute-executable-path-or-empty = $(call get-executable-or-default,variable,default)
-#
-define get-executable-or-default
-$(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2)))
-endef
-_ge_attempt = $(if $(get-executable),$(get-executable),$(call _gea_err,$(2)))
-_gea_err  = $(if $(1),$(error Please set '$(1)' appropriately))
diff --git a/tools/scripts/utilities.mak b/tools/scripts/utilities.mak
new file mode 100644
index 000000000000..c16ce833079c
--- /dev/null
+++ b/tools/scripts/utilities.mak
@@ -0,0 +1,179 @@
+# This allows us to work with the newline character:
+define newline
+
+
+endef
+newline := $(newline)
+
+# nl-escape
+#
+# Usage: escape = $(call nl-escape[,escape])
+#
+# This is used as the common way to specify
+# what should replace a newline when escaping
+# newlines; the default is a bizarre string.
+#
+nl-escape = $(if $(1),$(1),m822df3020w6a44id34bt574ctac44eb9f4n)
+
+# escape-nl
+#
+# Usage: escaped-text = $(call escape-nl,text[,escape])
+#
+# GNU make's $(shell ...) function converts to a
+# single space each newline character in the output
+# produced during the expansion; this may not be
+# desirable.
+#
+# The only solution is to change each newline into
+# something that won't be converted, so that the
+# information can be recovered later with
+# $(call unescape-nl...)
+#
+escape-nl = $(subst $(newline),$(call nl-escape,$(2)),$(1))
+
+# unescape-nl
+#
+# Usage: text = $(call unescape-nl,escaped-text[,escape])
+#
+# See escape-nl.
+#
+unescape-nl = $(subst $(call nl-escape,$(2)),$(newline),$(1))
+
+# shell-escape-nl
+#
+# Usage: $(shell some-command | $(call shell-escape-nl[,escape]))
+#
+# Use this to escape newlines from within a shell call;
+# the default escape is a bizarre string.
+#
+# NOTE: The escape is used directly as a string constant
+#       in an `awk' program that is delimited by shell
+#       single-quotes, so be wary of the characters
+#       that are chosen.
+#
+define shell-escape-nl
+awk 'NR==1 {t=$$0} NR>1 {t=t "$(nl-escape)" $$0} END {printf t}'
+endef
+
+# shell-unescape-nl
+#
+# Usage: $(shell some-command | $(call shell-unescape-nl[,escape]))
+#
+# Use this to unescape newlines from within a shell call;
+# the default escape is a bizarre string.
+#
+# NOTE: The escape is used directly as an extended regular
+#       expression constant in an `awk' program that is
+#       delimited by shell single-quotes, so be wary
+#       of the characters that are chosen.
+#
+# (The bash shell has a bug where `{gsub(...),...}' is
+#  misinterpreted as a brace expansion; this can be
+#  overcome by putting a space between `{' and `gsub').
+#
+define shell-unescape-nl
+awk 'NR==1 {t=$$0} NR>1 {t=t "\n" $$0} END { gsub(/$(nl-escape)/,"\n",t); printf t }'
+endef
+
+# escape-for-shell-sq
+#
+# Usage: embeddable-text = $(call escape-for-shell-sq,text)
+#
+# This function produces text that is suitable for
+# embedding in a shell string that is delimited by
+# single-quotes.
+#
+escape-for-shell-sq =  $(subst ','\'',$(1))
+
+# shell-sq
+#
+# Usage: single-quoted-and-escaped-text = $(call shell-sq,text)
+#
+shell-sq = '$(escape-for-shell-sq)'
+
+# shell-wordify
+#
+# Usage: wordified-text = $(call shell-wordify,text)
+#
+# For instance:
+#
+#  |define text
+#  |hello
+#  |world
+#  |endef
+#  |
+#  |target:
+#  |	echo $(call shell-wordify,$(text))
+#
+# At least GNU make gets confused by expanding a newline
+# within the context of a command line of a makefile rule
+# (this is in constrast to a `$(shell ...)' function call,
+# which can handle it just fine).
+#
+# This function avoids the problem by producing a string
+# that works as a shell word, regardless of whether or
+# not it contains a newline.
+#
+# If the text to be wordified contains a newline, then
+# an intrictate shell command substitution is constructed
+# to render the text as a single line; when the shell
+# processes the resulting escaped text, it transforms
+# it into the original unescaped text.
+#
+# If the text does not contain a newline, then this function
+# produces the same results as the `$(shell-sq)' function.
+#
+shell-wordify = $(if $(findstring $(newline),$(1)),$(_sw-esc-nl),$(shell-sq))
+define _sw-esc-nl
+"$$(echo $(call escape-nl,$(shell-sq),$(2)) | $(call shell-unescape-nl,$(2)))"
+endef
+
+# is-absolute
+#
+# Usage: bool-value = $(call is-absolute,path)
+#
+is-absolute = $(shell echo $(shell-sq) | grep -q ^/ && echo y)
+
+# lookup
+#
+# Usage: absolute-executable-path-or-empty = $(call lookup,path)
+#
+# (It's necessary to use `sh -c' because GNU make messes up by
+#  trying too hard and getting things wrong).
+#
+lookup = $(call unescape-nl,$(shell sh -c $(_l-sh)))
+_l-sh = $(call shell-sq,command -v $(shell-sq) | $(call shell-escape-nl,))
+
+# is-executable
+#
+# Usage: bool-value = $(call is-executable,path)
+#
+# (It's necessary to use `sh -c' because GNU make messes up by
+#  trying too hard and getting things wrong).
+#
+is-executable = $(call _is-executable-helper,$(shell-sq))
+_is-executable-helper = $(shell sh -c $(_is-executable-sh))
+_is-executable-sh = $(call shell-sq,test -f $(1) -a -x $(1) && echo y)
+
+# get-executable
+#
+# Usage: absolute-executable-path-or-empty = $(call get-executable,path)
+#
+# The goal is to get an absolute path for an executable;
+# the `command -v' is defined by POSIX, but it's not
+# necessarily very portable, so it's only used if
+# relative path resolution is requested, as determined
+# by the presence of a leading `/'.
+#
+get-executable = $(if $(1),$(if $(is-absolute),$(_ge-abspath),$(lookup)))
+_ge-abspath = $(if $(is-executable),$(1))
+
+# get-supplied-or-default-executable
+#
+# Usage: absolute-executable-path-or-empty = $(call get-executable-or-default,variable,default)
+#
+define get-executable-or-default
+$(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2)))
+endef
+_ge_attempt = $(if $(get-executable),$(get-executable),$(call _gea_err,$(2)))
+_gea_err  = $(if $(1),$(error Please set '$(1)' appropriately))
-- 
2.5.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ