From 85e4a889d3e08a39a8ebde594bab06e6fa732903 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 23 Apr 2020 16:39:15 +0900 Subject: Revert "objtool: Skip samples subdirectory" This reverts commit 8728497895794d1f207a836e02dae762ad175d56. samples/ contains only sub-directories. Because OBJECT_FILES_NON_STANDARD does not work recursively, this line has no effect. Signed-off-by: Masahiro Yamada Acked-by: Josh Poimboeuf Acked-by: Sam Ravnborg --- samples/Makefile | 1 - 1 file changed, 1 deletion(-) (limited to 'samples') diff --git a/samples/Makefile b/samples/Makefile index f8f847b4f61f..5ce50ef0f2b2 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -1,6 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux samples code -OBJECT_FILES_NON_STANDARD := y obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS) += binderfs/ obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs/ -- cgit v1.2.3-59-g8ed1b From f59e76687742fc2d6226e0d6449ae09c5942e9fc Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:16 +0900 Subject: samples: seccomp: build sample programs for target architecture These userspace programs include 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 programs should be built for the target as well. Kbuild now supports 'userprogs' for that. I also guarded the CONFIG option by 'depends on CC_CAN_LINK' because $(CC) may not provide libc. The 'ifndef CROSS_COMPILE' is no longer needed. BTW, the -m31 for s390 is left-over code. Commit 5a79859ae0f3 ("s390: remove 31 bit support") killed it. Signed-off-by: Masahiro Yamada Acked-by: Sam Ravnborg --- samples/Kconfig | 2 +- samples/seccomp/Makefile | 42 +++--------------------------------------- 2 files changed, 4 insertions(+), 40 deletions(-) (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index 9d236c346de5..8949e9646125 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -126,7 +126,7 @@ config SAMPLE_PIDFD config SAMPLE_SECCOMP bool "Build seccomp sample code" - depends on SECCOMP_FILTER && HEADERS_INSTALL + depends on SECCOMP_FILTER && CC_CAN_LINK && HEADERS_INSTALL help Build samples of seccomp filters using various methods of BPF filter construction. diff --git a/samples/seccomp/Makefile b/samples/seccomp/Makefile index 89279e8b87df..75916c23e416 100644 --- a/samples/seccomp/Makefile +++ b/samples/seccomp/Makefile @@ -1,44 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -ifndef CROSS_COMPILE -hostprogs := bpf-fancy dropper bpf-direct user-trap +userprogs := bpf-fancy dropper bpf-direct user-trap -HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include -HOSTCFLAGS_bpf-fancy.o += -idirafter $(objtree)/include -HOSTCFLAGS_bpf-helper.o += -I$(objtree)/usr/include -HOSTCFLAGS_bpf-helper.o += -idirafter $(objtree)/include bpf-fancy-objs := bpf-fancy.o bpf-helper.o -HOSTCFLAGS_dropper.o += -I$(objtree)/usr/include -HOSTCFLAGS_dropper.o += -idirafter $(objtree)/include -dropper-objs := dropper.o +userccflags += -I usr/include -HOSTCFLAGS_bpf-direct.o += -I$(objtree)/usr/include -HOSTCFLAGS_bpf-direct.o += -idirafter $(objtree)/include -bpf-direct-objs := bpf-direct.o - -HOSTCFLAGS_user-trap.o += -I$(objtree)/usr/include -HOSTCFLAGS_user-trap.o += -idirafter $(objtree)/include -user-trap-objs := user-trap.o - -# Try to match the kernel target. -ifndef CONFIG_64BIT - -# s390 has -m31 flag to build 31 bit binaries -ifndef CONFIG_S390 -MFLAG = -m32 -else -MFLAG = -m31 -endif - -HOSTCFLAGS_bpf-direct.o += $(MFLAG) -HOSTCFLAGS_dropper.o += $(MFLAG) -HOSTCFLAGS_bpf-helper.o += $(MFLAG) -HOSTCFLAGS_bpf-fancy.o += $(MFLAG) -HOSTCFLAGS_user-trap.o += $(MFLAG) -HOSTLDLIBS_bpf-direct += $(MFLAG) -HOSTLDLIBS_bpf-fancy += $(MFLAG) -HOSTLDLIBS_dropper += $(MFLAG) -HOSTLDLIBS_user-trap += $(MFLAG) -endif -always-y := $(hostprogs) -endif +always-y := $(userprogs) -- cgit v1.2.3-59-g8ed1b From 8a45fe7053a2c33b786706bdcd77d7ccf1531ef7 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 29 Apr 2020 12:45:18 +0900 Subject: samples: uhid: fix warnings in uhid-example Fix warnings seen when building for 32-bit architecture. Use "%xd" for arguments of type size_t to fix the warnings. Signed-off-by: Sam Ravnborg Signed-off-by: Masahiro Yamada --- samples/uhid/uhid-example.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'samples') diff --git a/samples/uhid/uhid-example.c b/samples/uhid/uhid-example.c index b72d645ce828..015cb06a241e 100644 --- a/samples/uhid/uhid-example.c +++ b/samples/uhid/uhid-example.c @@ -165,7 +165,7 @@ static int uhid_write(int fd, const struct uhid_event *ev) fprintf(stderr, "Cannot write to uhid: %m\n"); return -errno; } else if (ret != sizeof(*ev)) { - fprintf(stderr, "Wrong size written to uhid: %ld != %lu\n", + fprintf(stderr, "Wrong size written to uhid: %zd != %zu\n", ret, sizeof(ev)); return -EFAULT; } else { @@ -236,7 +236,7 @@ static int event(int fd) fprintf(stderr, "Cannot read uhid-cdev: %m\n"); return -errno; } else if (ret != sizeof(ev)) { - fprintf(stderr, "Invalid size read from uhid-dev: %ld != %lu\n", + fprintf(stderr, "Invalid size read from uhid-dev: %zd != %zu\n", ret, sizeof(ev)); return -EFAULT; } -- cgit v1.2.3-59-g8ed1b From 87ecdf4fc9fd98f2a4156716d75c342b5bd35c74 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:19 +0900 Subject: 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 Acked-by: Sam Ravnborg --- samples/Kconfig | 6 ++++++ samples/Makefile | 1 + samples/uhid/.gitignore | 2 ++ samples/uhid/Makefile | 9 +++------ 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 samples/uhid/.gitignore (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index 8949e9646125..2560e87c9cae 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -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 diff --git a/samples/Makefile b/samples/Makefile index 5ce50ef0f2b2..bdc168405452 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -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 index 000000000000..0e0a5a929f5d --- /dev/null +++ b/samples/uhid/.gitignore @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +/uhid-example diff --git a/samples/uhid/Makefile b/samples/uhid/Makefile index 5f44ea40d6d5..9e652fc34103 100644 --- a/samples/uhid/Makefile +++ b/samples/uhid/Makefile @@ -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 -- cgit v1.2.3-59-g8ed1b From 82d00a9392ecccc3828656e574bd62354a7259c9 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:20 +0900 Subject: samples: hidraw: 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. I also guarded the CONFIG option by 'depends on CC_CAN_LINK' because $(CC) may not provide libc. Signed-off-by: Masahiro Yamada Acked-by: Sam Ravnborg --- samples/Kconfig | 2 +- samples/hidraw/Makefile | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index 2560e87c9cae..08f2d025ca05 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -118,7 +118,7 @@ config SAMPLE_CONNECTOR config SAMPLE_HIDRAW bool "hidraw sample" - depends on HEADERS_INSTALL + depends on CC_CAN_LINK && HEADERS_INSTALL config SAMPLE_PIDFD bool "pidfd sample" diff --git a/samples/hidraw/Makefile b/samples/hidraw/Makefile index 8bd25f77671f..d2c77ed60b39 100644 --- a/samples/hidraw/Makefile +++ b/samples/hidraw/Makefile @@ -1,8 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -# List of programs to build -hostprogs := hid-example -always-y := $(hostprogs) +userprogs := hid-example +always-y := $(userprogs) -HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include - -all: hid-example +userccflags += -I usr/include -- cgit v1.2.3-59-g8ed1b From 37249f5945b77d009519efca9544151ea2a78596 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:21 +0900 Subject: samples: connector: 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. $(CC) can always compile cn_text.o since it is the kenrel-space code, but building ucon requires libc. I guarded it by: always-$(CONFIG_CC_CAN_LINK) := $(userprogs) Signed-off-by: Masahiro Yamada Acked-by: Sam Ravnborg --- samples/connector/Makefile | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'samples') diff --git a/samples/connector/Makefile b/samples/connector/Makefile index b785cbde5ffa..50cb40e09a7b 100644 --- a/samples/connector/Makefile +++ b/samples/connector/Makefile @@ -1,13 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_SAMPLE_CONNECTOR) += cn_test.o -# List of programs to build -hostprogs := ucon -always-y := $(hostprogs) +userprogs := ucon +always-$(CONFIG_CC_CAN_LINK) := $(userprogs) -HOSTCFLAGS_ucon.o += -I$(objtree)/usr/include - -all: modules - -modules clean: - $(MAKE) -C ../.. M=$(CURDIR) $@ +userccflags += -I usr/include -- cgit v1.2.3-59-g8ed1b From 28949b84b2cb2473507ec2fed06728f995dd7942 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:22 +0900 Subject: samples: vfs: build sample programs for target architecture These userspace programs include 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 programs should be built for the target as well. Kbuild now supports 'userprogs' for that. I also guarded the CONFIG option by 'depends on CC_CAN_LINK' because $(CC) may not provide libc. Signed-off-by: Masahiro Yamada Acked-by: Sam Ravnborg --- samples/Kconfig | 2 +- samples/vfs/Makefile | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index 08f2d025ca05..831a7ecd3352 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -184,7 +184,7 @@ config SAMPLE_ANDROID_BINDERFS config SAMPLE_VFS bool "Build example programs that use new VFS system calls" - depends on HEADERS_INSTALL + depends on CC_CAN_LINK && 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/vfs/Makefile b/samples/vfs/Makefile index 65acdde5c117..00b6824f9237 100644 --- a/samples/vfs/Makefile +++ b/samples/vfs/Makefile @@ -1,10 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -# List of programs to build -hostprogs := \ - test-fsmount \ - test-statx +userprogs := test-fsmount test-statx +always-y := $(userprogs) -always-y := $(hostprogs) - -HOSTCFLAGS_test-fsmount.o += -I$(objtree)/usr/include -HOSTCFLAGS_test-statx.o += -I$(objtree)/usr/include +userccflags += -I usr/include -- cgit v1.2.3-59-g8ed1b From 60fb0b1239719df2ec92606fa037f7c116810762 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:23 +0900 Subject: samples: pidfd: 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. I also guarded the CONFIG option by 'depends on CC_CAN_LINK' because $(CC) may not provide libc. Signed-off-by: Masahiro Yamada Acked-by: Sam Ravnborg --- samples/Kconfig | 2 +- samples/pidfd/Makefile | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index 831a7ecd3352..c68d391c0602 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -122,7 +122,7 @@ config SAMPLE_HIDRAW config SAMPLE_PIDFD bool "pidfd sample" - depends on HEADERS_INSTALL + depends on CC_CAN_LINK && HEADERS_INSTALL config SAMPLE_SECCOMP bool "Build seccomp sample code" diff --git a/samples/pidfd/Makefile b/samples/pidfd/Makefile index ee2979849d92..6e5b67e648c2 100644 --- a/samples/pidfd/Makefile +++ b/samples/pidfd/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -hostprogs := pidfd-metadata -always-y := $(hostprogs) -HOSTCFLAGS_pidfd-metadata.o += -I$(objtree)/usr/include -all: pidfd-metadata +usertprogs := pidfd-metadata +always-y := $(userprogs) + +userccflags += -I usr/include -- cgit v1.2.3-59-g8ed1b From c4c10996b1940e197b45f827b99f40a4b82daebb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:24 +0900 Subject: samples: mei: 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. I also guarded the CONFIG option by 'depends on CC_CAN_LINK' because $(CC) may not provide libc. Signed-off-by: Masahiro Yamada Acked-by: Sam Ravnborg --- samples/Kconfig | 1 + samples/mei/Makefile | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index c68d391c0602..69699db49675 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -193,6 +193,7 @@ config SAMPLE_VFS config SAMPLE_INTEL_MEI bool "Build example program working with intel mei driver" depends on INTEL_MEI + depends on CC_CAN_LINK && HEADERS_INSTALL help Build a sample program to work with mei device. diff --git a/samples/mei/Makefile b/samples/mei/Makefile index f5b9d02be2cd..329411f82369 100644 --- a/samples/mei/Makefile +++ b/samples/mei/Makefile @@ -1,10 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2012-2019, Intel Corporation. All rights reserved. -hostprogs := mei-amt-version +userprogs := mei-amt-version +always-y := $(userprogs) -HOSTCFLAGS_mei-amt-version.o += -I$(objtree)/usr/include - -always-y := $(hostprogs) - -all: mei-amt-version +userccflags += -I usr/include -- cgit v1.2.3-59-g8ed1b From 87ffbba9a9a1a74da44917a207c7e57dac98f2f8 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:25 +0900 Subject: samples: auxdisplay: use 'userprogs' syntax Kbuild now supports the 'userprogs' syntax to compile userspace programs for the same architecture as the kernel. 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 Acked-by: Miguel Ojeda Acked-by: Sam Ravnborg --- samples/Kconfig | 4 ++++ samples/Makefile | 1 + samples/auxdisplay/Makefile | 11 ++--------- 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index 69699db49675..2322e11e8b80 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -6,6 +6,10 @@ menuconfig SAMPLES if SAMPLES +config SAMPLE_AUXDISPLAY + bool "auxdisplay sample" + depends on CC_CAN_LINK + config SAMPLE_TRACE_EVENTS tristate "Build trace_events examples -- loadable modules only" depends on EVENT_TRACING && m diff --git a/samples/Makefile b/samples/Makefile index bdc168405452..0c43b5d34b15 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux samples code +subdir-$(CONFIG_SAMPLE_AUXDISPLAY) += auxdisplay obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS) += binderfs/ obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs/ obj-$(CONFIG_SAMPLE_CONNECTOR) += connector/ diff --git a/samples/auxdisplay/Makefile b/samples/auxdisplay/Makefile index 0273bab27233..dbdf939af94a 100644 --- a/samples/auxdisplay/Makefile +++ b/samples/auxdisplay/Makefile @@ -1,10 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 -CC := $(CROSS_COMPILE)gcc -CFLAGS := -I../../usr/include - -PROGS := cfag12864b-example - -all: $(PROGS) - -clean: - rm -fr $(PROGS) +userprogs := cfag12864b-example +always-y := $(userprogs) -- cgit v1.2.3-59-g8ed1b From b98ccc7150c7bfce60671ad1928d5f1220446b39 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:26 +0900 Subject: samples: timers: use 'userprogs' syntax Kbuild now supports the 'userprogs' syntax to compile userspace programs for the same architecture as the kernel. 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 Acked-by: Sam Ravnborg --- samples/Kconfig | 4 ++++ samples/Makefile | 1 + samples/timers/Makefile | 17 +++-------------- 3 files changed, 8 insertions(+), 14 deletions(-) (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index 2322e11e8b80..a8629a0d4f96 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -135,6 +135,10 @@ config SAMPLE_SECCOMP Build samples of seccomp filters using various methods of BPF filter construction. +config SAMPLE_TIMER + bool "Timer sample" + depends on CC_CAN_LINK && HEADERS_INSTALL + config SAMPLE_UHID bool "UHID sample" depends on CC_CAN_LINK && HEADERS_INSTALL diff --git a/samples/Makefile b/samples/Makefile index 0c43b5d34b15..042208326689 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -16,6 +16,7 @@ subdir-$(CONFIG_SAMPLE_PIDFD) += pidfd obj-$(CONFIG_SAMPLE_QMI_CLIENT) += qmi/ obj-$(CONFIG_SAMPLE_RPMSG_CLIENT) += rpmsg/ subdir-$(CONFIG_SAMPLE_SECCOMP) += seccomp +subdir-$(CONFIG_SAMPLE_TIMER) += timers obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace_events/ obj-$(CONFIG_SAMPLE_TRACE_PRINTK) += trace_printk/ obj-$(CONFIG_SAMPLE_FTRACE_DIRECT) += ftrace/ diff --git a/samples/timers/Makefile b/samples/timers/Makefile index f9fa07460802..15c7ddbc8c51 100644 --- a/samples/timers/Makefile +++ b/samples/timers/Makefile @@ -1,16 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ifndef CROSS_COMPILE -uname_M := $(shell uname -m 2>/dev/null || echo not) -ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) +userprogs := hpet_example +always-y := $(userprogs) -ifeq ($(ARCH),x86) -CC := $(CROSS_COMPILE)gcc -PROGS := hpet_example - -all: $(PROGS) - -clean: - rm -fr $(PROGS) - -endif -endif +userccflags += -I usr/include -- cgit v1.2.3-59-g8ed1b From 88a8e278ff0b6b461bf39d4ace17384e976a3f3f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 29 Apr 2020 12:45:27 +0900 Subject: samples: watchdog: use 'userprogs' syntax Kbuild now supports the 'userprogs' syntax to compile userspace programs for the same architecture as the kernel. 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 Acked-by: Sam Ravnborg --- samples/Kconfig | 3 +++ samples/Makefile | 1 + samples/watchdog/Makefile | 10 ++-------- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'samples') diff --git a/samples/Kconfig b/samples/Kconfig index a8629a0d4f96..5005f74ac0eb 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -205,5 +205,8 @@ config SAMPLE_INTEL_MEI help Build a sample program to work with mei device. +config SAMPLE_WATCHDOG + bool "watchdog sample" + depends on CC_CAN_LINK endif # SAMPLES diff --git a/samples/Makefile b/samples/Makefile index 042208326689..29c66aadd954 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -26,3 +26,4 @@ obj-$(CONFIG_VIDEO_PCI_SKELETON) += v4l/ obj-y += vfio-mdev/ subdir-$(CONFIG_SAMPLE_VFS) += vfs obj-$(CONFIG_SAMPLE_INTEL_MEI) += mei/ +subdir-$(CONFIG_SAMPLE_WATCHDOG) += watchdog diff --git a/samples/watchdog/Makefile b/samples/watchdog/Makefile index a9430fa60253..17384cfb387e 100644 --- a/samples/watchdog/Makefile +++ b/samples/watchdog/Makefile @@ -1,9 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 -CC := $(CROSS_COMPILE)gcc -PROGS := watchdog-simple - -all: $(PROGS) - -clean: - rm -fr $(PROGS) - +userprogs := watchdog-simple +always-y := $(userprogs) -- cgit v1.2.3-59-g8ed1b