[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191219083329.5926-2-masahiroy@kernel.org>
Date: Thu, 19 Dec 2019 17:33:27 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: linux-kbuild@...r.kernel.org
Cc: Lucas De Marchi <lucas.de.marchi@...il.com>,
Sam Ravnborg <sam@...nborg.org>, Jessica Yu <jeyu@...nel.org>,
Masahiro Yamada <masahiroy@...nel.org>,
Michal Marek <michal.lkml@...kovi.net>,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] kbuild: add stringify helper to quote a string passed to C files
Make $(squote)$(quote)...$(quote)$(squote) a helper macro.
I will reuse it in the next commit.
Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
---
scripts/Kbuild.include | 4 ++++
scripts/Makefile.lib | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index bc5f25763c1b..88c144787e57 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -32,6 +32,10 @@ real-prereqs = $(filter-out $(PHONY), $^)
# Escape single quote for use in echo statements
escsq = $(subst $(squote),'\$(squote)',$1)
+###
+# Quote a string to pass it to C files. foo => '"foo"'
+stringify = $(squote)$(quote)$1$(quote)$(squote)
+
###
# Easy method for doing a status message
kecho := :
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3fa32f83b2d7..e4c47ad2899d 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -93,7 +93,7 @@ target-stem = $(basename $(patsubst $(obj)/%,%,$@))
# These flags are needed for modversions and compiling, so we define them here
# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will
# end up in (or would, if it gets compiled in)
-name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
+name-fix = $(call stringify,$(subst $(comma),_,$(subst -,_,$1)))
basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname))
--
2.17.1
Powered by blists - more mailing lists