Makefile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. include ../scripts/Makefile.include
  3. bindir ?= /usr/bin
  4. ifeq ($(srctree),)
  5. srctree := $(patsubst %/,%,$(dir $(CURDIR)))
  6. srctree := $(patsubst %/,%,$(dir $(srctree)))
  7. endif
  8. # Do not use make's built-in rules
  9. # (this improves performance and avoids hard-to-debug behaviour);
  10. MAKEFLAGS += -r
  11. CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
  12. ALL_TARGETS := spidev_test spidev_fdx
  13. ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
  14. all: $(ALL_PROGRAMS)
  15. export srctree OUTPUT CC LD CFLAGS
  16. include $(srctree)/tools/build/Makefile.include
  17. #
  18. # We need the following to be outside of kernel tree
  19. #
  20. $(OUTPUT)include/linux/spi: ../../include/uapi/linux/spi
  21. mkdir -p $(OUTPUT)include/linux/spi 2>&1 || true
  22. ln -sf $(CURDIR)/../../include/uapi/linux/spi/spidev.h $@
  23. ln -sf $(CURDIR)/../../include/uapi/linux/spi/spi.h $@
  24. prepare: $(OUTPUT)include/linux/spi
  25. #
  26. # spidev_test
  27. #
  28. SPIDEV_TEST_IN := $(OUTPUT)spidev_test-in.o
  29. $(SPIDEV_TEST_IN): prepare FORCE
  30. $(Q)$(MAKE) $(build)=spidev_test
  31. $(OUTPUT)spidev_test: $(SPIDEV_TEST_IN)
  32. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
  33. #
  34. # spidev_fdx
  35. #
  36. SPIDEV_FDX_IN := $(OUTPUT)spidev_fdx-in.o
  37. $(SPIDEV_FDX_IN): prepare FORCE
  38. $(Q)$(MAKE) $(build)=spidev_fdx
  39. $(OUTPUT)spidev_fdx: $(SPIDEV_FDX_IN)
  40. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
  41. clean:
  42. rm -f $(ALL_PROGRAMS)
  43. rm -rf $(OUTPUT)include/
  44. find $(or $(OUTPUT),.) -name '*.o' -delete
  45. find $(or $(OUTPUT),.) -name '\.*.o.d' -delete
  46. find $(or $(OUTPUT),.) -name '\.*.o.cmd' -delete
  47. install: $(ALL_PROGRAMS)
  48. install -d -m 755 $(DESTDIR)$(bindir); \
  49. for program in $(ALL_PROGRAMS); do \
  50. install $$program $(DESTDIR)$(bindir); \
  51. done
  52. FORCE:
  53. .PHONY: all install clean FORCE prepare