spidev_test.mk 1.7 KB

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