xref: /OK3568_Linux_fs/buildroot/package/spidev_test/spidev_test.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# spidev_test
4#
5################################################################################
6
7# Build the latest version that is compatible with the toolchain's kernel headers
8# v3.15+ requires SPI_TX_QUAD/SPI_RX_QUAD to build
9# Normally kernel headers can't be newer than kernel so switch based on that.
10# If you need quad-pumped spi support you need to upgrade your toolchain.
11# Note that the location of spidev_test.c changes from v4.5 onwards.
12
13ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15),y)
14SPIDEV_TEST_VERSION = 4.10
15SPIDEV_TEST_PATH = tools/spi
16else
17SPIDEV_TEST_VERSION = 3.0
18SPIDEV_TEST_PATH = Documentation/spi
19endif
20
21SPIDEV_TEST_SITE = http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/$(SPIDEV_TEST_PATH)
22SPIDEV_TEST_SOURCE = spidev_test.c?id=v$(SPIDEV_TEST_VERSION)
23SPIDEV_TEST_LICENSE = GPL-2.0
24
25# musl libc requires linux/ioctl.h for _IOC_SIZEBITS. Do a sed patch to keep
26# compatibility with different spidev_test.c versions that we support.
27define SPIDEV_TEST_ADD_LINUX_IOCTL
28	$(SED) 's~^#include <sys/ioctl.h>~#include <sys/ioctl.h>\n#include <linux/ioctl.h>~' \
29		$(@D)/spidev_test.c
30endef
31
32SPIDEV_TEST_POST_PATCH_HOOKS += SPIDEV_TEST_ADD_LINUX_IOCTL
33
34define SPIDEV_TEST_EXTRACT_CMDS
35	cp $(SPIDEV_TEST_DL_DIR)/$(SPIDEV_TEST_SOURCE) $(@D)/spidev_test.c
36endef
37
38define SPIDEV_TEST_BUILD_CMDS
39	$(TARGET_MAKE_ENV) $(TARGET_CC) $(TARGET_CFLAGS) \
40		-o $(@D)/spidev_test $(@D)/spidev_test.c
41endef
42
43define SPIDEV_TEST_INSTALL_TARGET_CMDS
44	$(INSTALL) -D -m 755 $(@D)/spidev_test \
45		$(TARGET_DIR)/usr/sbin/spidev_test
46endef
47
48$(eval $(generic-package))
49