kconfig: add basic helper macros to scripts/Kconfig.include
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 28 May 2018 09:21:59 +0000 (18:21 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 28 May 2018 18:31:19 +0000 (03:31 +0900)
Kconfig got text processing tools like we see in Make.  Add Kconfig
helper macros to scripts/Kconfig.include like we collect Makefile
macros in scripts/Kbuild.include.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
Kconfig
MAINTAINERS
arch/x86/um/Kconfig
scripts/Kconfig.include [new file with mode: 0644]

diff --git a/Kconfig b/Kconfig
index 5b55d876af03346a4f1436ffdd2f0221b68ee91c..a90d9f9e268be8dac93cba2a699569884768e167 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -7,4 +7,6 @@ mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"
 
 comment "Compiler: $(CC_VERSION_TEXT)"
 
+source "scripts/Kconfig.include"
+
 source "arch/$(SRCARCH)/Kconfig"
index b87723a6ef326b7a6ea9a0c549b674c9742e3d67..79decb12cfbf3085e594944b15180a4352334426 100644 (file)
@@ -7639,6 +7639,7 @@ L:        linux-kbuild@vger.kernel.org
 S:     Maintained
 F:     Documentation/kbuild/kconfig*
 F:     scripts/kconfig/
+F:     scripts/Kconfig.include
 
 KDUMP
 M:     Dave Young <dyoung@redhat.com>
index a992f8e94887f9134c0f5ca0362d24afd4ea285c..9d529f22fd9d2e77e17fc56f3359b301f835d7ff 100644 (file)
@@ -3,6 +3,8 @@ mainmenu "User Mode Linux/$(SUBARCH) $(KERNELVERSION) Kernel Configuration"
 
 comment "Compiler: $(CC_VERSION_TEXT)"
 
+source "scripts/Kconfig.include"
+
 source "arch/um/Kconfig.common"
 
 menu "UML-specific options"
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
new file mode 100644 (file)
index 0000000..bf7c0c9
--- /dev/null
@@ -0,0 +1,27 @@
+# Kconfig helper macros
+
+# Convenient variables
+comma       := ,
+quote       := "
+squote      := '
+empty       :=
+space       := $(empty) $(empty)
+dollar      := $
+right_paren := )
+left_paren  := (
+
+# $(if-success,<command>,<then>,<else>)
+# Return <then> if <command> exits with 0, <else> otherwise.
+if-success = $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
+
+# $(success,<command>)
+# Return y if <command> exits with 0, n otherwise
+success = $(if-success,$(1),y,n)
+
+# $(cc-option,<flag>)
+# Return y if the compiler supports <flag>, n otherwise
+cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
+
+# $(ld-option,<flag>)
+# Return y if the linker supports <flag>, n otherwise
+ld-option = $(success,$(LD) -v $(1))