spidev_test.mk 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_3_15),y)
  12. SPIDEV_TEST_VERSION = 4.10
  13. SPIDEV_TEST_PATH = tools/spi
  14. else
  15. SPIDEV_TEST_VERSION = 3.0
  16. SPIDEV_TEST_PATH = Documentation/spi
  17. endif
  18. SPIDEV_TEST_SITE = http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/$(SPIDEV_TEST_PATH)
  19. SPIDEV_TEST_SOURCE = spidev_test.c?id=v$(SPIDEV_TEST_VERSION)
  20. SPIDEV_TEST_LICENSE = GPL-2.0
  21. # musl libc requires linux/ioctl.h for _IOC_SIZEBITS. Do a sed patch to keep
  22. # compatibility with different spidev_test.c versions that we support.
  23. define SPIDEV_ADD_LINUX_IOCTL
  24. $(SED) 's~^#include <sys/ioctl.h>~#include <sys/ioctl.h>\n#include <linux/ioctl.h>~' \
  25. $(@D)/spidev_test.c
  26. endef
  27. SPIDEV_TEST_POST_PATCH_HOOKS += SPIDEV_ADD_LINUX_IOCTL
  28. define SPIDEV_TEST_EXTRACT_CMDS
  29. cp $(SPIDEV_TEST_DL_DIR)/$(SPIDEV_TEST_SOURCE) $(@D)/spidev_test.c
  30. endef
  31. define SPIDEV_TEST_BUILD_CMDS
  32. $(TARGET_MAKE_ENV) $(TARGET_CC) $(TARGET_CFLAGS) \
  33. -o $(@D)/spidev_test $(@D)/spidev_test.c
  34. endef
  35. define SPIDEV_TEST_INSTALL_TARGET_CMDS
  36. $(INSTALL) -D -m 755 $(@D)/spidev_test \
  37. $(TARGET_DIR)/usr/sbin/spidev_test
  38. endef
  39. $(eval $(generic-package))