Skip to content

Commit

Permalink
samples: uhid: build sample program for target architecture
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
  • Loading branch information
masahir0y committed May 17, 2020
1 parent 8a45fe7 commit 87ecdf4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions samples/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ config SAMPLE_SECCOMP
Build samples of seccomp filters using various methods of
BPF filter construction.

config SAMPLE_UHID
bool "UHID sample"
depends on CC_CAN_LINK && HEADERS_INSTALL
help
Build UHID sample program.

config SAMPLE_VFIO_MDEV_MTTY
tristate "Build VFIO mtty example mediated device sample code -- loadable modules only"
depends on VFIO_MDEV_DEVICE && m
Expand Down
1 change: 1 addition & 0 deletions samples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace_events/
obj-$(CONFIG_SAMPLE_TRACE_PRINTK) += trace_printk/
obj-$(CONFIG_SAMPLE_FTRACE_DIRECT) += ftrace/
obj-$(CONFIG_SAMPLE_TRACE_ARRAY) += ftrace/
subdir-$(CONFIG_SAMPLE_UHID) += uhid
obj-$(CONFIG_VIDEO_PCI_SKELETON) += v4l/
obj-y += vfio-mdev/
subdir-$(CONFIG_SAMPLE_VFS) += vfs
Expand Down
2 changes: 2 additions & 0 deletions samples/uhid/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: GPL-2.0-only
/uhid-example
9 changes: 3 additions & 6 deletions samples/uhid/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
# List of programs to build
hostprogs := uhid-example
userprogs := uhid-example
always-y := $(userprogs)

# Tell kbuild to always build the programs
always-y := $(hostprogs)

HOSTCFLAGS_uhid-example.o += -I$(objtree)/usr/include
userccflags += -I usr/include

0 comments on commit 87ecdf4

Please sign in to comment.