blob: d4d956020adf5ec92067269bdedb79ce7da75402 [file] [log] [blame]
Andy Shevchenko18956cf2017-07-29 03:36:04 +03001include ../scripts/Makefile.include
2
Andy Shevchenko25e3f852017-07-29 03:36:05 +03003bindir ?= /usr/bin
4
Andy Shevchenko18956cf2017-07-29 03:36:04 +03005ifeq ($(srctree),)
6srctree := $(patsubst %/,%,$(dir $(CURDIR)))
7srctree := $(patsubst %/,%,$(dir $(srctree)))
8endif
9
10# Do not use make's built-in rules
11# (this improves performance and avoids hard-to-debug behaviour);
12MAKEFLAGS += -r
13
Linus Walleij54628682015-05-05 10:42:12 +020014CC = $(CROSS_COMPILE)gcc
Andy Shevchenko18956cf2017-07-29 03:36:04 +030015LD = $(CROSS_COMPILE)ld
16CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
Roberta Dobrescu817020c2015-02-26 10:49:25 +020017
Andy Shevchenko18956cf2017-07-29 03:36:04 +030018ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer
19ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
Peter Robinson0c4b6502016-05-25 14:31:13 +010020
Andy Shevchenko18956cf2017-07-29 03:36:04 +030021all: $(ALL_PROGRAMS)
Roberta Dobrescu817020c2015-02-26 10:49:25 +020022
Andy Shevchenko18956cf2017-07-29 03:36:04 +030023export srctree OUTPUT CC LD CFLAGS
24include $(srctree)/tools/build/Makefile.include
Roberta Dobrescu817020c2015-02-26 10:49:25 +020025
Andy Shevchenko18956cf2017-07-29 03:36:04 +030026#
27# We need the following to be outside of kernel tree
28#
29$(OUTPUT)include/linux/iio: ../../include/uapi/linux/iio
30 mkdir -p $(OUTPUT)include/linux/iio 2>&1 || true
31 ln -sf $(CURDIR)/../../include/uapi/linux/iio/events.h $@
32 ln -sf $(CURDIR)/../../include/uapi/linux/iio/types.h $@
Roberta Dobrescu817020c2015-02-26 10:49:25 +020033
Andy Shevchenko18956cf2017-07-29 03:36:04 +030034prepare: $(OUTPUT)include/linux/iio
Roberta Dobrescu817020c2015-02-26 10:49:25 +020035
Andy Shevchenko18956cf2017-07-29 03:36:04 +030036LSIIO_IN := $(OUTPUT)lsiio-in.o
37$(LSIIO_IN): prepare FORCE
38 $(Q)$(MAKE) $(build)=lsiio
39$(OUTPUT)lsiio: $(LSIIO_IN)
40 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
Roberta Dobrescu817020c2015-02-26 10:49:25 +020041
Andy Shevchenko18956cf2017-07-29 03:36:04 +030042IIO_EVENT_MONITOR_IN := $(OUTPUT)iio_event_monitor-in.o
43$(IIO_EVENT_MONITOR_IN): prepare FORCE
44 $(Q)$(MAKE) $(build)=iio_event_monitor
45$(OUTPUT)iio_event_monitor: $(IIO_EVENT_MONITOR_IN)
46 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
Peter Robinson0c4b6502016-05-25 14:31:13 +010047
Andy Shevchenko18956cf2017-07-29 03:36:04 +030048IIO_GENERIC_BUFFER_IN := $(OUTPUT)iio_generic_buffer-in.o
49$(IIO_GENERIC_BUFFER_IN): prepare FORCE
50 $(Q)$(MAKE) $(build)=iio_generic_buffer
51$(OUTPUT)iio_generic_buffer: $(IIO_GENERIC_BUFFER_IN)
52 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
Peter Robinson0c4b6502016-05-25 14:31:13 +010053
Roberta Dobrescu817020c2015-02-26 10:49:25 +020054clean:
Andy Shevchenko18956cf2017-07-29 03:36:04 +030055 rm -f $(ALL_PROGRAMS)
56 rm -rf $(OUTPUT)include/linux/iio
57 find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
58
Andy Shevchenko25e3f852017-07-29 03:36:05 +030059install: $(ALL_PROGRAMS)
60 install -d -m 755 $(DESTDIR)$(bindir); \
61 for program in $(ALL_PROGRAMS); do \
62 install $$program $(DESTDIR)$(bindir); \
63 done
64
Andy Shevchenko18956cf2017-07-29 03:36:04 +030065FORCE:
66
Andy Shevchenko25e3f852017-07-29 03:36:05 +030067.PHONY: all install clean FORCE prepare