Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi...
[sfrench/cifs-2.6.git] / tools / iio / Makefile
1 include ../scripts/Makefile.include
2
3 bindir ?= /usr/bin
4
5 ifeq ($(srctree),)
6 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
7 srctree := $(patsubst %/,%,$(dir $(srctree)))
8 endif
9
10 # Do not use make's built-in rules
11 # (this improves performance and avoids hard-to-debug behaviour);
12 MAKEFLAGS += -r
13
14 CC = $(CROSS_COMPILE)gcc
15 LD = $(CROSS_COMPILE)ld
16 CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
17
18 ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer
19 ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
20
21 all: $(ALL_PROGRAMS)
22
23 export srctree OUTPUT CC LD CFLAGS
24 include $(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
34 prepare: $(OUTPUT)include/linux/iio
35
36 LSIIO_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
42 IIO_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
48 IIO_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
54 clean:
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
59 install: $(ALL_PROGRAMS)
60         install -d -m 755 $(DESTDIR)$(bindir);          \
61         for program in $(ALL_PROGRAMS); do              \
62                 install $$program $(DESTDIR)$(bindir);  \
63         done
64
65 FORCE:
66
67 .PHONY: all install clean FORCE prepare