linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS
@ 2019-04-27  3:33 Masahiro Yamada
  2019-04-27  3:33 ` [PATCH 2/5] kbuild: move Documentation to vmlinux-alldirs Masahiro Yamada
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Masahiro Yamada @ 2019-04-27  3:33 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

Handle samples/ like the other top-level directories to simplify
the Makefile.

Include include/config/auto.conf earlier to evaluate
drivers-$(CONFIG_SAMPLES).

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 Makefile         | 18 ++++++++----------
 samples/Makefile |  2 +-
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 15e17b4..251ded5 100644
--- a/Makefile
+++ b/Makefile
@@ -598,20 +598,21 @@ endif
 
 export KBUILD_MODULES KBUILD_BUILTIN
 
+ifeq ($(dot-config),1)
+include include/config/auto.conf
+endif
+
 ifeq ($(KBUILD_EXTMOD),)
 # Objects we will link into vmlinux / subdirs we need to visit
 init-y		:= init/
 drivers-y	:= drivers/ sound/
+drivers-$(CONFIG_SAMPLES) += samples/
 net-y		:= net/
 libs-y		:= lib/
 core-y		:= usr/
 virt-y		:= virt/
 endif # KBUILD_EXTMOD
 
-ifeq ($(dot-config),1)
-include include/config/auto.conf
-endif
-
 # The all: target is the default when no target is given on the
 # command line.
 # This allow a user to issue only 'make' to build a kernel including modules
@@ -1005,7 +1006,7 @@ export KBUILD_VMLINUX_LIBS := $(libs-y1)
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
 export LDFLAGS_vmlinux
 # used by scripts/package/Makefile
-export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools)
+export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include scripts tools)
 
 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
 
@@ -1042,11 +1043,8 @@ vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
 
 targets := vmlinux
 
-# Build samples along the rest of the kernel. This needs headers_install.
-ifdef CONFIG_SAMPLES
-vmlinux-dirs += samples
+# Some samples need headers_install.
 samples: headers_install
-endif
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
@@ -1362,7 +1360,7 @@ MRPROPER_FILES += .config .config.old .version \
 #
 clean: rm-dirs  := $(CLEAN_DIRS)
 clean: rm-files := $(CLEAN_FILES)
-clean-dirs      := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation samples)
+clean-dirs      := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation)
 
 PHONY += $(clean-dirs) clean archclean vmlinuxclean
 $(clean-dirs):
diff --git a/samples/Makefile b/samples/Makefile
index b1142a9..50f8586 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -1,6 +1,6 @@
 # Makefile for Linux samples code
 
-obj-$(CONFIG_SAMPLES)	+= kobject/ kprobes/ trace_events/ livepatch/ \
+obj-y			+= kobject/ kprobes/ trace_events/ livepatch/ \
 			   hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
 			   configfs/ connector/ v4l/ trace_printk/ \
 			   vfio-mdev/ statx/ qmi/ binderfs/
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] kbuild: move Documentation to vmlinux-alldirs
  2019-04-27  3:33 [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS Masahiro Yamada
@ 2019-04-27  3:33 ` Masahiro Yamada
  2019-04-27  3:33 ` [PATCH 3/5] samples: guard sub-directories with CONFIG options Masahiro Yamada
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2019-04-27  3:33 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

A minor code cleanup.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 Makefile | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 251ded5..334ef8a 100644
--- a/Makefile
+++ b/Makefile
@@ -988,8 +988,9 @@ vmlinux-dirs	:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
 		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
 		     $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y)))
 
-vmlinux-alldirs	:= $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \
-		     $(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-))))
+vmlinux-alldirs	:= $(sort $(vmlinux-dirs) Documentation \
+		     $(patsubst %/,%,$(filter %/, $(init-) $(core-) \
+			$(drivers-) $(net-) $(libs-) $(virt-))))
 
 init-y		:= $(patsubst %/, %/built-in.a, $(init-y))
 core-y		:= $(patsubst %/, %/built-in.a, $(core-y))
@@ -1006,7 +1007,7 @@ export KBUILD_VMLINUX_LIBS := $(libs-y1)
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
 export LDFLAGS_vmlinux
 # used by scripts/package/Makefile
-export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include scripts tools)
+export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch include scripts tools)
 
 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
 
@@ -1360,7 +1361,7 @@ MRPROPER_FILES += .config .config.old .version \
 #
 clean: rm-dirs  := $(CLEAN_DIRS)
 clean: rm-files := $(CLEAN_FILES)
-clean-dirs      := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation)
+clean-dirs      := $(addprefix _clean_, . $(vmlinux-alldirs))
 
 PHONY += $(clean-dirs) clean archclean vmlinuxclean
 $(clean-dirs):
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] samples: guard sub-directories with CONFIG options
  2019-04-27  3:33 [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS Masahiro Yamada
  2019-04-27  3:33 ` [PATCH 2/5] kbuild: move Documentation to vmlinux-alldirs Masahiro Yamada
@ 2019-04-27  3:33 ` Masahiro Yamada
  2019-04-27  3:33 ` [PATCH 4/5] samples: seccomp: turn CONFIG_SAMPLE_SECCOMP into a bool option Masahiro Yamada
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2019-04-27  3:33 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, linux-kernel

Do not descend to sub-directories when unneeded.

I used subdir-$(CONFIG_...) for hidraw, seccomp, and statx because
they only contain host programs.

While we are here, let's add SPDX License tag, and sort the directories
alphabetically.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 samples/Makefile | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/samples/Makefile b/samples/Makefile
index 50f8586..0f2d70d 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -1,6 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0
 # Makefile for Linux samples code
 
-obj-y			+= kobject/ kprobes/ trace_events/ livepatch/ \
-			   hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
-			   configfs/ connector/ v4l/ trace_printk/ \
-			   vfio-mdev/ statx/ qmi/ binderfs/
+obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS)	+= binderfs/
+obj-$(CONFIG_SAMPLE_CONFIGFS)		+= configfs/
+obj-$(CONFIG_SAMPLE_CONNECTOR)		+= connector/
+subdir-y				+= hidraw
+obj-$(CONFIG_SAMPLE_HW_BREAKPOINT)	+= hw_breakpoint/
+obj-$(CONFIG_SAMPLE_KDB)		+= kdb/
+obj-$(CONFIG_SAMPLE_KFIFO)		+= kfifo/
+obj-$(CONFIG_SAMPLE_KOBJECT)		+= kobject/
+obj-$(CONFIG_SAMPLE_KPROBES)		+= kprobes/
+obj-$(CONFIG_SAMPLE_LIVEPATCH)		+= livepatch/
+obj-$(CONFIG_SAMPLE_QMI_CLIENT)		+= qmi/
+obj-$(CONFIG_SAMPLE_RPMSG_CLIENT)	+= rpmsg/
+subdir-$(CONFIG_SAMPLE_SECCOMP)		+= seccomp
+subdir-$(CONFIG_SAMPLE_STATX)		+= statx
+obj-$(CONFIG_SAMPLE_TRACE_EVENTS)	+= trace_events/
+obj-$(CONFIG_SAMPLE_TRACE_PRINTK)	+= trace_printk/
+obj-$(CONFIG_VIDEO_PCI_SKELETON)	+= v4l/
+obj-y					+= vfio-mdev/
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] samples: seccomp: turn CONFIG_SAMPLE_SECCOMP into a bool option
  2019-04-27  3:33 [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS Masahiro Yamada
  2019-04-27  3:33 ` [PATCH 2/5] kbuild: move Documentation to vmlinux-alldirs Masahiro Yamada
  2019-04-27  3:33 ` [PATCH 3/5] samples: guard sub-directories with CONFIG options Masahiro Yamada
@ 2019-04-27  3:33 ` Masahiro Yamada
  2019-04-27  3:33 ` [PATCH 5/5] samples: kobject: allow CONFIG_SAMPLE_KOBJECT to become y Masahiro Yamada
  2019-05-01 12:35 ` [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS Masahiro Yamada
  4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2019-04-27  3:33 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, linux-kernel

The prompt of CONFIG_SAMPLE_SECCOMP claims this is "loadable module
only", which is invalid.

samples/seccomp/ only contains host programs, so having it tristate
is pointless.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 samples/Kconfig          | 4 ++--
 samples/seccomp/Makefile | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/samples/Kconfig b/samples/Kconfig
index d19754c..b98a763 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -103,8 +103,8 @@ config SAMPLE_CONNECTOR
 	  See also Documentation/connector/connector.txt
 
 config SAMPLE_SECCOMP
-	tristate "Build seccomp sample code -- loadable modules only"
-	depends on SECCOMP_FILTER && m
+	bool "Build seccomp sample code"
+	depends on SECCOMP_FILTER
 	help
 	  Build samples of seccomp filters using various methods of
 	  BPF filter construction.
diff --git a/samples/seccomp/Makefile b/samples/seccomp/Makefile
index fb43a81..00e0b5e 100644
--- a/samples/seccomp/Makefile
+++ b/samples/seccomp/Makefile
@@ -40,5 +40,5 @@ HOSTLDLIBS_bpf-fancy += $(MFLAG)
 HOSTLDLIBS_dropper += $(MFLAG)
 HOSTLDLIBS_user-trap += $(MFLAG)
 endif
-always := $(hostprogs-m)
+always := $(hostprogs-y)
 endif
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] samples: kobject: allow CONFIG_SAMPLE_KOBJECT to become y
  2019-04-27  3:33 [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS Masahiro Yamada
                   ` (2 preceding siblings ...)
  2019-04-27  3:33 ` [PATCH 4/5] samples: seccomp: turn CONFIG_SAMPLE_SECCOMP into a bool option Masahiro Yamada
@ 2019-04-27  3:33 ` Masahiro Yamada
  2019-05-01 12:35 ` [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS Masahiro Yamada
  4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2019-04-27  3:33 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, linux-kernel

This sample works well as builtin.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 samples/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/samples/Kconfig b/samples/Kconfig
index b98a763..399ae53 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -20,8 +20,7 @@ config SAMPLE_TRACE_PRINTK
 	 test various trace_printk() calls from a module.
 
 config SAMPLE_KOBJECT
-	tristate "Build kobject examples -- loadable modules only"
-	depends on m
+	tristate "Build kobject examples"
 	help
 	  This config option will allow you to build a number of
 	  different kobject sample modules showing how to use kobjects,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS
  2019-04-27  3:33 [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS Masahiro Yamada
                   ` (3 preceding siblings ...)
  2019-04-27  3:33 ` [PATCH 5/5] samples: kobject: allow CONFIG_SAMPLE_KOBJECT to become y Masahiro Yamada
@ 2019-05-01 12:35 ` Masahiro Yamada
  4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2019-05-01 12:35 UTC (permalink / raw)
  To: Linux Kbuild mailing list; +Cc: Michal Marek, Linux Kernel Mailing List

On Sat, Apr 27, 2019 at 12:34 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> Handle samples/ like the other top-level directories to simplify
> the Makefile.
>
> Include include/config/auto.conf earlier to evaluate
> drivers-$(CONFIG_SAMPLES).
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---

Series, applied to linux-kbuild.



>  Makefile         | 18 ++++++++----------
>  samples/Makefile |  2 +-
>  2 files changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 15e17b4..251ded5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -598,20 +598,21 @@ endif
>
>  export KBUILD_MODULES KBUILD_BUILTIN
>
> +ifeq ($(dot-config),1)
> +include include/config/auto.conf
> +endif
> +
>  ifeq ($(KBUILD_EXTMOD),)
>  # Objects we will link into vmlinux / subdirs we need to visit
>  init-y         := init/
>  drivers-y      := drivers/ sound/
> +drivers-$(CONFIG_SAMPLES) += samples/
>  net-y          := net/
>  libs-y         := lib/
>  core-y         := usr/
>  virt-y         := virt/
>  endif # KBUILD_EXTMOD
>
> -ifeq ($(dot-config),1)
> -include include/config/auto.conf
> -endif
> -
>  # The all: target is the default when no target is given on the
>  # command line.
>  # This allow a user to issue only 'make' to build a kernel including modules
> @@ -1005,7 +1006,7 @@ export KBUILD_VMLINUX_LIBS := $(libs-y1)
>  export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
>  export LDFLAGS_vmlinux
>  # used by scripts/package/Makefile
> -export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools)
> +export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include scripts tools)
>
>  vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
>
> @@ -1042,11 +1043,8 @@ vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
>
>  targets := vmlinux
>
> -# Build samples along the rest of the kernel. This needs headers_install.
> -ifdef CONFIG_SAMPLES
> -vmlinux-dirs += samples
> +# Some samples need headers_install.
>  samples: headers_install
> -endif
>
>  # The actual objects are generated when descending,
>  # make sure no implicit rule kicks in
> @@ -1362,7 +1360,7 @@ MRPROPER_FILES += .config .config.old .version \
>  #
>  clean: rm-dirs  := $(CLEAN_DIRS)
>  clean: rm-files := $(CLEAN_FILES)
> -clean-dirs      := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation samples)
> +clean-dirs      := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation)
>
>  PHONY += $(clean-dirs) clean archclean vmlinuxclean
>  $(clean-dirs):
> diff --git a/samples/Makefile b/samples/Makefile
> index b1142a9..50f8586 100644
> --- a/samples/Makefile
> +++ b/samples/Makefile
> @@ -1,6 +1,6 @@
>  # Makefile for Linux samples code
>
> -obj-$(CONFIG_SAMPLES)  += kobject/ kprobes/ trace_events/ livepatch/ \
> +obj-y                  += kobject/ kprobes/ trace_events/ livepatch/ \
>                            hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
>                            configfs/ connector/ v4l/ trace_printk/ \
>                            vfio-mdev/ statx/ qmi/ binderfs/
> --
> 2.7.4
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-01 12:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-27  3:33 [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS Masahiro Yamada
2019-04-27  3:33 ` [PATCH 2/5] kbuild: move Documentation to vmlinux-alldirs Masahiro Yamada
2019-04-27  3:33 ` [PATCH 3/5] samples: guard sub-directories with CONFIG options Masahiro Yamada
2019-04-27  3:33 ` [PATCH 4/5] samples: seccomp: turn CONFIG_SAMPLE_SECCOMP into a bool option Masahiro Yamada
2019-04-27  3:33 ` [PATCH 5/5] samples: kobject: allow CONFIG_SAMPLE_KOBJECT to become y Masahiro Yamada
2019-05-01 12:35 ` [PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).