Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 1 | include ../scripts/Makefile.include |
| 2 | |
Andy Shevchenko | 25e3f85 | 2017-07-29 03:36:05 +0300 | [diff] [blame] | 3 | bindir ?= /usr/bin |
| 4 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 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 | |
Linus Walleij | 5462868 | 2015-05-05 10:42:12 +0200 | [diff] [blame] | 14 | CC = $(CROSS_COMPILE)gcc |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 15 | LD = $(CROSS_COMPILE)ld |
| 16 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include |
Roberta Dobrescu | 817020c | 2015-02-26 10:49:25 +0200 | [diff] [blame] | 17 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 18 | ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer |
| 19 | ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) |
Peter Robinson | 0c4b650 | 2016-05-25 14:31:13 +0100 | [diff] [blame] | 20 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 21 | all: $(ALL_PROGRAMS) |
Roberta Dobrescu | 817020c | 2015-02-26 10:49:25 +0200 | [diff] [blame] | 22 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 23 | export srctree OUTPUT CC LD CFLAGS |
| 24 | include $(srctree)/tools/build/Makefile.include |
Roberta Dobrescu | 817020c | 2015-02-26 10:49:25 +0200 | [diff] [blame] | 25 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 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 $@ |
Roberta Dobrescu | 817020c | 2015-02-26 10:49:25 +0200 | [diff] [blame] | 33 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 34 | prepare: $(OUTPUT)include/linux/iio |
Roberta Dobrescu | 817020c | 2015-02-26 10:49:25 +0200 | [diff] [blame] | 35 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 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 $@ |
Roberta Dobrescu | 817020c | 2015-02-26 10:49:25 +0200 | [diff] [blame] | 41 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 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 $@ |
Peter Robinson | 0c4b650 | 2016-05-25 14:31:13 +0100 | [diff] [blame] | 47 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 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 $@ |
Peter Robinson | 0c4b650 | 2016-05-25 14:31:13 +0100 | [diff] [blame] | 53 | |
Roberta Dobrescu | 817020c | 2015-02-26 10:49:25 +0200 | [diff] [blame] | 54 | clean: |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 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 | |
Andy Shevchenko | 25e3f85 | 2017-07-29 03:36:05 +0300 | [diff] [blame] | 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 | |
Andy Shevchenko | 18956cf | 2017-07-29 03:36:04 +0300 | [diff] [blame] | 65 | FORCE: |
| 66 | |
Andy Shevchenko | 25e3f85 | 2017-07-29 03:36:05 +0300 | [diff] [blame] | 67 | .PHONY: all install clean FORCE prepare |