xref: /kernel/linux/linux-5.10/tools/iio/Makefile (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ciinclude ../scripts/Makefile.include
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_cibindir ?= /usr/bin
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciifeq ($(srctree),)
78c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(CURDIR)))
88c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
98c2ecf20Sopenharmony_ciendif
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci# Do not use make's built-in rules
128c2ecf20Sopenharmony_ci# (this improves performance and avoids hard-to-debug behaviour);
138c2ecf20Sopenharmony_ciMAKEFLAGS += -r
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cioverride CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer
188c2ecf20Sopenharmony_ciALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciall: $(ALL_PROGRAMS)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciexport srctree OUTPUT CC LD CFLAGS
238c2ecf20Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.include
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#
268c2ecf20Sopenharmony_ci# We need the following to be outside of kernel tree
278c2ecf20Sopenharmony_ci#
288c2ecf20Sopenharmony_ci$(OUTPUT)include/linux/iio: ../../include/uapi/linux/iio
298c2ecf20Sopenharmony_ci	mkdir -p $(OUTPUT)include/linux/iio 2>&1 || true
308c2ecf20Sopenharmony_ci	ln -sf $(CURDIR)/../../include/uapi/linux/iio/events.h $@
318c2ecf20Sopenharmony_ci	ln -sf $(CURDIR)/../../include/uapi/linux/iio/types.h $@
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciprepare: $(OUTPUT)include/linux/iio
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciIIO_UTILS_IN := $(OUTPUT)iio_utils-in.o
368c2ecf20Sopenharmony_ci$(IIO_UTILS_IN): prepare FORCE
378c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=iio_utils
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciLSIIO_IN := $(OUTPUT)lsiio-in.o
408c2ecf20Sopenharmony_ci$(LSIIO_IN): prepare FORCE $(OUTPUT)iio_utils-in.o
418c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=lsiio
428c2ecf20Sopenharmony_ci$(OUTPUT)lsiio: $(LSIIO_IN)
438c2ecf20Sopenharmony_ci	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ciIIO_EVENT_MONITOR_IN := $(OUTPUT)iio_event_monitor-in.o
468c2ecf20Sopenharmony_ci$(IIO_EVENT_MONITOR_IN): prepare FORCE $(OUTPUT)iio_utils-in.o
478c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=iio_event_monitor
488c2ecf20Sopenharmony_ci$(OUTPUT)iio_event_monitor: $(IIO_EVENT_MONITOR_IN)
498c2ecf20Sopenharmony_ci	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ciIIO_GENERIC_BUFFER_IN := $(OUTPUT)iio_generic_buffer-in.o
528c2ecf20Sopenharmony_ci$(IIO_GENERIC_BUFFER_IN): prepare FORCE $(OUTPUT)iio_utils-in.o
538c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=iio_generic_buffer
548c2ecf20Sopenharmony_ci$(OUTPUT)iio_generic_buffer: $(IIO_GENERIC_BUFFER_IN)
558c2ecf20Sopenharmony_ci	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ciclean:
588c2ecf20Sopenharmony_ci	rm -f $(ALL_PROGRAMS)
598c2ecf20Sopenharmony_ci	rm -rf $(OUTPUT)include/linux/iio
608c2ecf20Sopenharmony_ci	find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ciinstall: $(ALL_PROGRAMS)
638c2ecf20Sopenharmony_ci	install -d -m 755 $(DESTDIR)$(bindir);		\
648c2ecf20Sopenharmony_ci	for program in $(ALL_PROGRAMS); do		\
658c2ecf20Sopenharmony_ci		install $$program $(DESTDIR)$(bindir);	\
668c2ecf20Sopenharmony_ci	done
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ciFORCE:
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci.PHONY: all install clean FORCE prepare
71