samples: uhid: build sample program for target architecture
authorMasahiro Yamada <masahiroy@kernel.org>
Wed, 29 Apr 2020 03:45:19 +0000 (12:45 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sun, 17 May 2020 09:52:01 +0000 (18:52 +0900)
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>
samples/Kconfig
samples/Makefile
samples/uhid/.gitignore [new file with mode: 0644]
samples/uhid/Makefile

index 8949e964612525cd34cd7ce1a2b16bc86cef8fac..2560e87c9cae67772e83682fb3878c2e06490d07 100644 (file)
@@ -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
index 5ce50ef0f2b2eed9b48ec06aba1202afd3f0e515..bdc16840545274e5882bf74bb8b93c9f84e4bf9e 100644 (file)
@@ -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
diff --git a/samples/uhid/.gitignore b/samples/uhid/.gitignore
new file mode 100644 (file)
index 0000000..0e0a5a9
--- /dev/null
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+/uhid-example
index 5f44ea40d6d5e4591e69978a00d37513ea8bff3d..9e652fc34103472a603737321758c1bee5cfee8f 100644 (file)
@@ -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