Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/spidev.h: ../../include/uapi/linux/spi/spidev.h
  21. mkdir -p $(OUTPUT)include/linux/spi 2>&1 || true
  22. ln -sf $(CURDIR)/../../include/uapi/linux/spi/spidev.h $@
  23. prepare: $(OUTPUT)include/linux/spi/spidev.h
  24. #
  25. # spidev_test
  26. #
  27. SPIDEV_TEST_IN := $(OUTPUT)spidev_test-in.o
  28. $(SPIDEV_TEST_IN): prepare FORCE
  29. $(Q)$(MAKE) $(build)=spidev_test
  30. $(OUTPUT)spidev_test: $(SPIDEV_TEST_IN)
  31. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
  32. #
  33. # spidev_fdx
  34. #
  35. SPIDEV_FDX_IN := $(OUTPUT)spidev_fdx-in.o
  36. $(SPIDEV_FDX_IN): prepare FORCE
  37. $(Q)$(MAKE) $(build)=spidev_fdx
  38. $(OUTPUT)spidev_fdx: $(SPIDEV_FDX_IN)
  39. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
  40. clean:
  41. rm -f $(ALL_PROGRAMS)
  42. rm -rf $(OUTPUT)include/
  43. find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete
  44. find $(if $(OUTPUT),$(OUTPUT),.) -name '\.*.o.d' -delete
  45. find $(if $(OUTPUT),$(OUTPUT),.) -name '\.*.o.cmd' -delete
  46. install: $(ALL_PROGRAMS)
  47. install -d -m 755 $(DESTDIR)$(bindir); \
  48. for program in $(ALL_PROGRAMS); do \
  49. install $$program $(DESTDIR)$(bindir); \
  50. done
  51. FORCE:
  52. .PHONY: all install clean FORCE prepare