Makefile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 -f $(OUTPUT)include/linux/spi/spidev.h
  43. find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
  44. install: $(ALL_PROGRAMS)
  45. install -d -m 755 $(DESTDIR)$(bindir); \
  46. for program in $(ALL_PROGRAMS); do \
  47. install $$program $(DESTDIR)$(bindir); \
  48. done
  49. FORCE:
  50. .PHONY: all install clean FORCE prepare