Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # SPDX-License-Identifier: GPL-2.0
  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 := iio_event_monitor lsiio iio_generic_buffer
  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/iio: ../../include/uapi/linux/iio
  21. mkdir -p $(OUTPUT)include/linux/iio 2>&1 || true
  22. ln -sf $(CURDIR)/../../include/uapi/linux/iio/events.h $@
  23. ln -sf $(CURDIR)/../../include/uapi/linux/iio/types.h $@
  24. prepare: $(OUTPUT)include/linux/iio
  25. LSIIO_IN := $(OUTPUT)lsiio-in.o
  26. $(LSIIO_IN): prepare FORCE
  27. $(Q)$(MAKE) $(build)=lsiio
  28. $(OUTPUT)lsiio: $(LSIIO_IN)
  29. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
  30. IIO_EVENT_MONITOR_IN := $(OUTPUT)iio_event_monitor-in.o
  31. $(IIO_EVENT_MONITOR_IN): prepare FORCE
  32. $(Q)$(MAKE) $(build)=iio_event_monitor
  33. $(OUTPUT)iio_event_monitor: $(IIO_EVENT_MONITOR_IN)
  34. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
  35. IIO_GENERIC_BUFFER_IN := $(OUTPUT)iio_generic_buffer-in.o
  36. $(IIO_GENERIC_BUFFER_IN): prepare FORCE
  37. $(Q)$(MAKE) $(build)=iio_generic_buffer
  38. $(OUTPUT)iio_generic_buffer: $(IIO_GENERIC_BUFFER_IN)
  39. $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
  40. clean:
  41. rm -f $(ALL_PROGRAMS)
  42. rm -rf $(OUTPUT)include/linux/iio
  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