Makefile 1.6 KB

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