kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of samples
Commit 5318321d36
("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 <yamada.masahiro@socionext.com>
This commit is contained in:
parent
c6509a24d6
commit
e949f4c2d6
8
Makefile
8
Makefile
|
@ -1053,9 +1053,6 @@ vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
|
||||||
|
|
||||||
targets := vmlinux
|
targets := vmlinux
|
||||||
|
|
||||||
# Some samples need headers_install.
|
|
||||||
samples: headers_install
|
|
||||||
|
|
||||||
# The actual objects are generated when descending,
|
# The actual objects are generated when descending,
|
||||||
# make sure no implicit rule kicks in
|
# make sure no implicit rule kicks in
|
||||||
$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
|
$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
|
||||||
|
@ -1199,6 +1196,10 @@ headers_check: headers_install
|
||||||
$(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1
|
$(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1
|
||||||
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi dst=include HDRCHECK=1
|
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi dst=include HDRCHECK=1
|
||||||
|
|
||||||
|
ifdef CONFIG_HEADERS_INSTALL
|
||||||
|
prepare: headers_install
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef CONFIG_HEADERS_CHECK
|
ifdef CONFIG_HEADERS_CHECK
|
||||||
all: headers_check
|
all: headers_check
|
||||||
endif
|
endif
|
||||||
|
@ -1744,7 +1745,6 @@ build-dir = $(patsubst %/,%,$(dir $(build-target)))
|
||||||
PHONY += /
|
PHONY += /
|
||||||
/: ./
|
/: ./
|
||||||
|
|
||||||
samples/: headers_install
|
|
||||||
%/: prepare FORCE
|
%/: prepare FORCE
|
||||||
$(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir)
|
$(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir)
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ CONFIG_CONFIGFS_FS=y
|
||||||
CONFIG_DEBUG_INFO=y
|
CONFIG_DEBUG_INFO=y
|
||||||
CONFIG_STRIP_ASM_SYMS=y
|
CONFIG_STRIP_ASM_SYMS=y
|
||||||
CONFIG_DEBUG_FS=y
|
CONFIG_DEBUG_FS=y
|
||||||
|
CONFIG_HEADERS_INSTALL=y
|
||||||
CONFIG_HEADERS_CHECK=y
|
CONFIG_HEADERS_CHECK=y
|
||||||
CONFIG_DEBUG_SECTION_MISMATCH=y
|
CONFIG_DEBUG_SECTION_MISMATCH=y
|
||||||
CONFIG_MAGIC_SYSRQ=y
|
CONFIG_MAGIC_SYSRQ=y
|
||||||
|
|
|
@ -92,6 +92,7 @@ CONFIG_DEBUG_INFO=y
|
||||||
CONFIG_DEBUG_INFO_DWARF4=y
|
CONFIG_DEBUG_INFO_DWARF4=y
|
||||||
CONFIG_GDB_SCRIPTS=y
|
CONFIG_GDB_SCRIPTS=y
|
||||||
CONFIG_READABLE_ASM=y
|
CONFIG_READABLE_ASM=y
|
||||||
|
CONFIG_HEADERS_INSTALL=y
|
||||||
CONFIG_HEADERS_CHECK=y
|
CONFIG_HEADERS_CHECK=y
|
||||||
CONFIG_DEBUG_SECTION_MISMATCH=y
|
CONFIG_DEBUG_SECTION_MISMATCH=y
|
||||||
CONFIG_MAGIC_SYSRQ=y
|
CONFIG_MAGIC_SYSRQ=y
|
||||||
|
|
|
@ -166,6 +166,7 @@ CONFIG_NLS_ISO8859_1=m
|
||||||
CONFIG_NLS_ISO8859_15=m
|
CONFIG_NLS_ISO8859_15=m
|
||||||
CONFIG_NLS_UTF8=m
|
CONFIG_NLS_UTF8=m
|
||||||
CONFIG_DEBUG_FS=y
|
CONFIG_DEBUG_FS=y
|
||||||
|
CONFIG_HEADERS_INSTALL=y
|
||||||
CONFIG_HEADERS_CHECK=y
|
CONFIG_HEADERS_CHECK=y
|
||||||
CONFIG_MAGIC_SYSRQ=y
|
CONFIG_MAGIC_SYSRQ=y
|
||||||
# CONFIG_DEBUG_BUGVERBOSE is not set
|
# CONFIG_DEBUG_BUGVERBOSE is not set
|
||||||
|
|
|
@ -90,6 +90,7 @@ CONFIG_NLS_ASCII=m
|
||||||
CONFIG_NLS_ISO8859_1=m
|
CONFIG_NLS_ISO8859_1=m
|
||||||
CONFIG_NLS_ISO8859_15=m
|
CONFIG_NLS_ISO8859_15=m
|
||||||
CONFIG_NLS_UTF8=m
|
CONFIG_NLS_UTF8=m
|
||||||
|
CONFIG_HEADERS_INSTALL=y
|
||||||
CONFIG_HEADERS_CHECK=y
|
CONFIG_HEADERS_CHECK=y
|
||||||
CONFIG_MAGIC_SYSRQ=y
|
CONFIG_MAGIC_SYSRQ=y
|
||||||
CONFIG_DEBUG_KERNEL=y
|
CONFIG_DEBUG_KERNEL=y
|
||||||
|
|
|
@ -139,6 +139,7 @@ CONFIG_NLS_ISO8859_1=m
|
||||||
CONFIG_NLS_ISO8859_15=m
|
CONFIG_NLS_ISO8859_15=m
|
||||||
CONFIG_NLS_UTF8=m
|
CONFIG_NLS_UTF8=m
|
||||||
CONFIG_DEBUG_FS=y
|
CONFIG_DEBUG_FS=y
|
||||||
|
CONFIG_HEADERS_INSTALL=y
|
||||||
CONFIG_HEADERS_CHECK=y
|
CONFIG_HEADERS_CHECK=y
|
||||||
CONFIG_MAGIC_SYSRQ=y
|
CONFIG_MAGIC_SYSRQ=y
|
||||||
CONFIG_DEBUG_MUTEXES=y
|
CONFIG_DEBUG_MUTEXES=y
|
||||||
|
|
|
@ -183,6 +183,7 @@ CONFIG_NLS_KOI8_R=m
|
||||||
CONFIG_NLS_KOI8_U=m
|
CONFIG_NLS_KOI8_U=m
|
||||||
CONFIG_NLS_UTF8=y
|
CONFIG_NLS_UTF8=y
|
||||||
CONFIG_DEBUG_FS=y
|
CONFIG_DEBUG_FS=y
|
||||||
|
CONFIG_HEADERS_INSTALL=y
|
||||||
CONFIG_HEADERS_CHECK=y
|
CONFIG_HEADERS_CHECK=y
|
||||||
CONFIG_MAGIC_SYSRQ=y
|
CONFIG_MAGIC_SYSRQ=y
|
||||||
CONFIG_DEBUG_KERNEL=y
|
CONFIG_DEBUG_KERNEL=y
|
||||||
|
|
|
@ -1124,6 +1124,7 @@ CONFIG_NLS_KOI8_R=m
|
||||||
CONFIG_NLS_KOI8_U=m
|
CONFIG_NLS_KOI8_U=m
|
||||||
CONFIG_DEBUG_INFO=y
|
CONFIG_DEBUG_INFO=y
|
||||||
CONFIG_UNUSED_SYMBOLS=y
|
CONFIG_UNUSED_SYMBOLS=y
|
||||||
|
CONFIG_HEADERS_INSTALL=y
|
||||||
CONFIG_HEADERS_CHECK=y
|
CONFIG_HEADERS_CHECK=y
|
||||||
CONFIG_MAGIC_SYSRQ=y
|
CONFIG_MAGIC_SYSRQ=y
|
||||||
CONFIG_DEBUG_KERNEL=y
|
CONFIG_DEBUG_KERNEL=y
|
||||||
|
|
|
@ -586,6 +586,7 @@ CONFIG_GDB_SCRIPTS=y
|
||||||
CONFIG_FRAME_WARN=1024
|
CONFIG_FRAME_WARN=1024
|
||||||
CONFIG_READABLE_ASM=y
|
CONFIG_READABLE_ASM=y
|
||||||
CONFIG_UNUSED_SYMBOLS=y
|
CONFIG_UNUSED_SYMBOLS=y
|
||||||
|
CONFIG_HEADERS_INSTALL=y
|
||||||
CONFIG_HEADERS_CHECK=y
|
CONFIG_HEADERS_CHECK=y
|
||||||
CONFIG_DEBUG_SECTION_MISMATCH=y
|
CONFIG_DEBUG_SECTION_MISMATCH=y
|
||||||
CONFIG_MAGIC_SYSRQ=y
|
CONFIG_MAGIC_SYSRQ=y
|
||||||
|
|
|
@ -305,14 +305,23 @@ config DEBUG_FS
|
||||||
|
|
||||||
If unsure, say N.
|
If unsure, say N.
|
||||||
|
|
||||||
config HEADERS_CHECK
|
config HEADERS_INSTALL
|
||||||
bool "Run sanity checks on uapi headers when building 'all'"
|
bool "Install uapi headers to usr/include"
|
||||||
depends on !UML
|
depends on !UML
|
||||||
help
|
help
|
||||||
This option will extract the user-visible kernel headers when
|
This option will install uapi headers (headers exported to user-space)
|
||||||
building the 'all' target, and will run basic sanity checks on them to
|
into the usr/include directory for use during the kernel build.
|
||||||
ensure that exported files do not attempt to include files which
|
This is unneeded for building the kernel itself, but needed for some
|
||||||
were not exported, etc.
|
user-space program samples. It is also needed by some features such
|
||||||
|
as uapi header sanity checks.
|
||||||
|
|
||||||
|
config HEADERS_CHECK
|
||||||
|
bool "Run sanity checks on uapi headers when building 'all'"
|
||||||
|
depends on HEADERS_INSTALL
|
||||||
|
help
|
||||||
|
This option will run basic sanity checks on uapi headers when
|
||||||
|
building the 'all' target, for example, ensure that they do not
|
||||||
|
attempt to include files which were not exported, etc.
|
||||||
|
|
||||||
If you're making modifications to header files which are
|
If you're making modifications to header files which are
|
||||||
relevant for userspace, say 'Y', and check the headers
|
relevant for userspace, say 'Y', and check the headers
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
menuconfig SAMPLES
|
menuconfig SAMPLES
|
||||||
bool "Sample kernel code"
|
bool "Sample kernel code"
|
||||||
depends on !UML
|
|
||||||
help
|
help
|
||||||
You can build and test sample kernel code here.
|
You can build and test sample kernel code here.
|
||||||
|
|
||||||
|
@ -95,16 +94,24 @@ config SAMPLE_CONFIGFS
|
||||||
|
|
||||||
config SAMPLE_CONNECTOR
|
config SAMPLE_CONNECTOR
|
||||||
tristate "Build connector sample -- loadable modules only"
|
tristate "Build connector sample -- loadable modules only"
|
||||||
depends on CONNECTOR && m
|
depends on CONNECTOR && HEADERS_INSTALL && m
|
||||||
help
|
help
|
||||||
When enabled, this builds both a sample kernel module for
|
When enabled, this builds both a sample kernel module for
|
||||||
the connector interface and a user space tool to communicate
|
the connector interface and a user space tool to communicate
|
||||||
with it.
|
with it.
|
||||||
See also Documentation/connector/connector.txt
|
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
|
config SAMPLE_SECCOMP
|
||||||
bool "Build seccomp sample code"
|
bool "Build seccomp sample code"
|
||||||
depends on SECCOMP_FILTER
|
depends on SECCOMP_FILTER && HEADERS_INSTALL
|
||||||
help
|
help
|
||||||
Build samples of seccomp filters using various methods of
|
Build samples of seccomp filters using various methods of
|
||||||
BPF filter construction.
|
BPF filter construction.
|
||||||
|
@ -156,6 +163,7 @@ config SAMPLE_ANDROID_BINDERFS
|
||||||
|
|
||||||
config SAMPLE_VFS
|
config SAMPLE_VFS
|
||||||
bool "Build example programs that use new VFS system calls"
|
bool "Build example programs that use new VFS system calls"
|
||||||
|
depends on HEADERS_INSTALL
|
||||||
help
|
help
|
||||||
Build example userspace programs that use new VFS system calls such
|
Build example userspace programs that use new VFS system calls such
|
||||||
as mount API and statx(). Note that this is restricted to the x86
|
as mount API and statx(). Note that this is restricted to the x86
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS) += binderfs/
|
obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS) += binderfs/
|
||||||
obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs/
|
obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs/
|
||||||
obj-$(CONFIG_SAMPLE_CONNECTOR) += connector/
|
obj-$(CONFIG_SAMPLE_CONNECTOR) += connector/
|
||||||
subdir-y += hidraw
|
subdir-$(CONFIG_SAMPLE_HIDRAW) += hidraw
|
||||||
obj-$(CONFIG_SAMPLE_HW_BREAKPOINT) += hw_breakpoint/
|
obj-$(CONFIG_SAMPLE_HW_BREAKPOINT) += hw_breakpoint/
|
||||||
obj-$(CONFIG_SAMPLE_KDB) += kdb/
|
obj-$(CONFIG_SAMPLE_KDB) += kdb/
|
||||||
obj-$(CONFIG_SAMPLE_KFIFO) += kfifo/
|
obj-$(CONFIG_SAMPLE_KFIFO) += kfifo/
|
||||||
obj-$(CONFIG_SAMPLE_KOBJECT) += kobject/
|
obj-$(CONFIG_SAMPLE_KOBJECT) += kobject/
|
||||||
obj-$(CONFIG_SAMPLE_KPROBES) += kprobes/
|
obj-$(CONFIG_SAMPLE_KPROBES) += kprobes/
|
||||||
obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch/
|
obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch/
|
||||||
subdir-y += pidfd
|
subdir-$(CONFIG_SAMPLE_PIDFD) += pidfd
|
||||||
obj-$(CONFIG_SAMPLE_QMI_CLIENT) += qmi/
|
obj-$(CONFIG_SAMPLE_QMI_CLIENT) += qmi/
|
||||||
obj-$(CONFIG_SAMPLE_RPMSG_CLIENT) += rpmsg/
|
obj-$(CONFIG_SAMPLE_RPMSG_CLIENT) += rpmsg/
|
||||||
subdir-$(CONFIG_SAMPLE_SECCOMP) += seccomp
|
subdir-$(CONFIG_SAMPLE_SECCOMP) += seccomp
|
||||||
|
|
Loading…
Reference in a new issue