From e949f4c2d6a3df2b7fd00e56c0f081b15284906f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Jun 2019 19:13:59 +0900 Subject: kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of samples Commit 5318321d367c ("samples: disable CONFIG_SAMPLES for UML") used a big hammer to fix the build errors under the samples/ directory. Only some samples actually include uapi headers from usr/include. Introduce CONFIG_HEADERS_INSTALL since 'depends on HEADERS_INSTALL' is clearer than 'depends on !UML'. If this option is enabled, uapi headers are installed before starting directory descending. I added 'depends on HEADERS_INSTALL' to per-sample CONFIG options. This allows UML to compile some samples. $ make ARCH=um allmodconfig samples/ [ snip ] CC [M] samples/configfs/configfs_sample.o CC [M] samples/kfifo/bytestream-example.o CC [M] samples/kfifo/dma-example.o CC [M] samples/kfifo/inttype-example.o CC [M] samples/kfifo/record-example.o CC [M] samples/kobject/kobject-example.o CC [M] samples/kobject/kset-example.o CC [M] samples/trace_events/trace-events-sample.o CC [M] samples/trace_printk/trace-printk.o AR samples/vfio-mdev/built-in.a AR samples/built-in.a Signed-off-by: Masahiro Yamada --- samples/Kconfig | 14 +++++++++++--- samples/Makefile | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index d63cc8a3e0df2..71b5e833dd9e7 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only menuconfig SAMPLES bool "Sample kernel code" - depends on !UML help You can build and test sample kernel code here. @@ -95,16 +94,24 @@ config SAMPLE_CONFIGFS config SAMPLE_CONNECTOR tristate "Build connector sample -- loadable modules only" - depends on CONNECTOR && m + depends on CONNECTOR && HEADERS_INSTALL && m help When enabled, this builds both a sample kernel module for the connector interface and a user space tool to communicate with it. See also Documentation/connector/connector.txt +config SAMPLE_HIDRAW + bool "hidraw sample" + depends on HEADERS_INSTALL + +config SAMPLE_PIDFD + bool "pidfd sample" + depends on HEADERS_INSTALL + config SAMPLE_SECCOMP bool "Build seccomp sample code" - depends on SECCOMP_FILTER + depends on SECCOMP_FILTER && HEADERS_INSTALL help Build samples of seccomp filters using various methods of BPF filter construction. @@ -156,6 +163,7 @@ config SAMPLE_ANDROID_BINDERFS config SAMPLE_VFS bool "Build example programs that use new VFS system calls" + depends on HEADERS_INSTALL help Build example userspace programs that use new VFS system calls such as mount API and statx(). Note that this is restricted to the x86 diff --git a/samples/Makefile b/samples/Makefile index debf8925f06f4..7d6e4ca28d696 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -4,14 +4,14 @@ obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS) += binderfs/ obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs/ obj-$(CONFIG_SAMPLE_CONNECTOR) += connector/ -subdir-y += hidraw +subdir-$(CONFIG_SAMPLE_HIDRAW) += 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/ -subdir-y += pidfd +subdir-$(CONFIG_SAMPLE_PIDFD) += pidfd obj-$(CONFIG_SAMPLE_QMI_CLIENT) += qmi/ obj-$(CONFIG_SAMPLE_RPMSG_CLIENT) += rpmsg/ subdir-$(CONFIG_SAMPLE_SECCOMP) += seccomp -- cgit v1.2.3