xref: /openbmc/linux/tools/iio/Makefile (revision 5a244f48)
1include ../scripts/Makefile.include
2
3bindir ?= /usr/bin
4
5ifeq ($(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
14CC = $(CROSS_COMPILE)gcc
15LD = $(CROSS_COMPILE)ld
16CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
17
18ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer
19ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
20
21all: $(ALL_PROGRAMS)
22
23export srctree OUTPUT CC LD CFLAGS
24include $(srctree)/tools/build/Makefile.include
25
26#
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 $@
33
34prepare: $(OUTPUT)include/linux/iio
35
36LSIIO_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 $@
41
42IIO_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 $@
47
48IIO_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 $@
53
54clean:
55	rm -f $(ALL_PROGRAMS)
56	rm -rf $(OUTPUT)include/linux/iio
57	find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
58
59install: $(ALL_PROGRAMS)
60	install -d -m 755 $(DESTDIR)$(bindir);		\
61	for program in $(ALL_PROGRAMS); do		\
62		install $$program $(DESTDIR)$(bindir);	\
63	done
64
65FORCE:
66
67.PHONY: all install clean FORCE prepare
68