Skip to content

Commit 87ecdf4

Browse files
committed
samples: uhid: build sample program for target architecture
This userspace program includes UAPI headers exported to usr/include/. 'make headers' always works for the target architecture (i.e. the same architecture as the kernel), so the sample program should be built for the target as well. Kbuild now supports 'userprogs' for that. Add the entry to samples/Makefile to put this into the build bot coverage. I also added the CONFIG option guarded by 'depends on CC_CAN_LINK' because $(CC) may not provide libc. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Sam Ravnborg <sam@ravnborg.org>
1 parent 8a45fe7 commit 87ecdf4

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎samples/Kconfig‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ config SAMPLE_SECCOMP
131131
Build samples of seccomp filters using various methods of
132132
BPF filter construction.
133133

134+
config SAMPLE_UHID
135+
bool "UHID sample"
136+
depends on CC_CAN_LINK && HEADERS_INSTALL
137+
help
138+
Build UHID sample program.
139+
134140
config SAMPLE_VFIO_MDEV_MTTY
135141
tristate "Build VFIO mtty example mediated device sample code -- loadable modules only"
136142
depends on VFIO_MDEV_DEVICE && m

‎samples/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace_events/
1919
obj-$(CONFIG_SAMPLE_TRACE_PRINTK) += trace_printk/
2020
obj-$(CONFIG_SAMPLE_FTRACE_DIRECT) += ftrace/
2121
obj-$(CONFIG_SAMPLE_TRACE_ARRAY) += ftrace/
22+
subdir-$(CONFIG_SAMPLE_UHID) += uhid
2223
obj-$(CONFIG_VIDEO_PCI_SKELETON) += v4l/
2324
obj-y += vfio-mdev/
2425
subdir-$(CONFIG_SAMPLE_VFS) += vfs

‎samples/uhid/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
/uhid-example

‎samples/uhid/Makefile‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
# List of programs to build
3-
hostprogs := uhid-example
2+
userprogs := uhid-example
3+
always-y := $(userprogs)
44

5-
# Tell kbuild to always build the programs
6-
always-y := $(hostprogs)
7-
8-
HOSTCFLAGS_uhid-example.o += -I$(objtree)/usr/include
5+
userccflags += -I usr/include

0 commit comments

Comments
 (0)