* [PATCH v1 1/2] iio: tools: move to tools buildsystem
@ 2017-07-29 0:36 Andy Shevchenko
2017-07-29 0:36 ` [PATCH v1 2/2] iio: tools: add install section Andy Shevchenko
2017-07-30 16:28 ` [PATCH v1 1/2] iio: tools: move to tools buildsystem Jonathan Cameron
0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2017-07-29 0:36 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen, Hartmut Knaack,
eter Meerwald-Stadler, linux-iio, David Lechner
Cc: Andy Shevchenko
There is a nice buildsystem dedicated for userspace tools in Linux kernel tree.
Switch iio target to be built by it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
tools/iio/Build | 3 +++
tools/iio/Makefile | 68 ++++++++++++++++++++++++++++++++++++++----------------
2 files changed, 51 insertions(+), 20 deletions(-)
create mode 100644 tools/iio/Build
diff --git a/tools/iio/Build b/tools/iio/Build
new file mode 100644
index 000000000000..f74cbda64710
--- /dev/null
+++ b/tools/iio/Build
@@ -0,0 +1,3 @@
+lsiio-y += lsiio.o iio_utils.o
+iio_event_monitor-y += iio_event_monitor.o iio_utils.o
+iio_generic_buffer-y += iio_generic_buffer.o iio_utils.o
diff --git a/tools/iio/Makefile b/tools/iio/Makefile
index 8f08e03a9a5e..5581c062421a 100644
--- a/tools/iio/Makefile
+++ b/tools/iio/Makefile
@@ -1,31 +1,59 @@
+include ../scripts/Makefile.include
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(CURDIR)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+endif
+
+# Do not use make's built-in rules
+# (this improves performance and avoids hard-to-debug behaviour);
+MAKEFLAGS += -r
+
CC = $(CROSS_COMPILE)gcc
-CFLAGS += -Wall -g -D_GNU_SOURCE -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include
+LD = $(CROSS_COMPILE)ld
+CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
-BINDIR=usr/bin
-INSTALL_PROGRAM=install -m 755 -p
-DEL_FILE=rm -f
+ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer
+ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
-all: iio_event_monitor lsiio iio_generic_buffer
+all: $(ALL_PROGRAMS)
-iio_event_monitor: iio_event_monitor.o iio_utils.o
+export srctree OUTPUT CC LD CFLAGS
+include $(srctree)/tools/build/Makefile.include
-lsiio: lsiio.o iio_utils.o
+#
+# We need the following to be outside of kernel tree
+#
+$(OUTPUT)include/linux/iio: ../../include/uapi/linux/iio
+ mkdir -p $(OUTPUT)include/linux/iio 2>&1 || true
+ ln -sf $(CURDIR)/../../include/uapi/linux/iio/events.h $@
+ ln -sf $(CURDIR)/../../include/uapi/linux/iio/types.h $@
-iio_generic_buffer: iio_generic_buffer.o iio_utils.o
+prepare: $(OUTPUT)include/linux/iio
-%.o: %.c iio_utils.h
+LSIIO_IN := $(OUTPUT)lsiio-in.o
+$(LSIIO_IN): prepare FORCE
+ $(Q)$(MAKE) $(build)=lsiio
+$(OUTPUT)lsiio: $(LSIIO_IN)
+ $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
-install:
- - mkdir -p $(INSTALL_ROOT)/$(BINDIR)
- - $(INSTALL_PROGRAM) "iio_event_monitor" "$(INSTALL_ROOT)/$(BINDIR)/iio_event_monitor"
- - $(INSTALL_PROGRAM) "lsiio" "$(INSTALL_ROOT)/$(BINDIR)/lsiio"
- - $(INSTALL_PROGRAM) "iio_generic_buffer" "$(INSTALL_ROOT)/$(BINDIR)/iio_generic_buffer"
+IIO_EVENT_MONITOR_IN := $(OUTPUT)iio_event_monitor-in.o
+$(IIO_EVENT_MONITOR_IN): prepare FORCE
+ $(Q)$(MAKE) $(build)=iio_event_monitor
+$(OUTPUT)iio_event_monitor: $(IIO_EVENT_MONITOR_IN)
+ $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
-uninstall:
- $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/iio_event_monitor"
- $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/lsiio"
- $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/iio_generic_buffer"
+IIO_GENERIC_BUFFER_IN := $(OUTPUT)iio_generic_buffer-in.o
+$(IIO_GENERIC_BUFFER_IN): prepare FORCE
+ $(Q)$(MAKE) $(build)=iio_generic_buffer
+$(OUTPUT)iio_generic_buffer: $(IIO_GENERIC_BUFFER_IN)
+ $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
-.PHONY: clean
clean:
- rm -f *.o iio_event_monitor lsiio iio_generic_buffer
+ rm -f $(ALL_PROGRAMS)
+ rm -rf $(OUTPUT)include/linux/iio
+ find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
+
+FORCE:
+
+.PHONY: all clean FORCE prepare
--
2.13.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/2] iio: tools: add install section
2017-07-29 0:36 [PATCH v1 1/2] iio: tools: move to tools buildsystem Andy Shevchenko
@ 2017-07-29 0:36 ` Andy Shevchenko
2017-07-30 16:30 ` Jonathan Cameron
2017-07-30 16:28 ` [PATCH v1 1/2] iio: tools: move to tools buildsystem Jonathan Cameron
1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2017-07-29 0:36 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen, Hartmut Knaack,
eter Meerwald-Stadler, linux-iio, David Lechner
Cc: Andy Shevchenko
Allow user to call install target.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
tools/Makefile | 6 +++---
tools/iio/Makefile | 10 +++++++++-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/tools/Makefile b/tools/Makefile
index 616e7722b327..f3f5f45b6355 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -93,7 +93,7 @@ kvm_stat: FORCE
all: acpi cgroup cpupower gpio hv firewire lguest liblockdep \
perf selftests spi turbostat usb \
virtio vm net x86_energy_perf_policy \
- tmon freefall objtool kvm_stat
+ tmon freefall iio objtool kvm_stat
acpi_install:
$(call descend,power/$(@:_install=),install)
@@ -101,7 +101,7 @@ acpi_install:
cpupower_install:
$(call descend,power/$(@:_install=),install)
-cgroup_install firewire_install gpio_install hv_install lguest_install perf_install spi_install usb_install virtio_install vm_install net_install objtool_install:
+cgroup_install firewire_install gpio_install hv_install iio_install lguest_install perf_install spi_install usb_install virtio_install vm_install net_install objtool_install:
$(call descend,$(@:_install=),install)
liblockdep_install:
@@ -123,7 +123,7 @@ kvm_stat_install:
$(call descend,kvm/$(@:_install=),install)
install: acpi_install cgroup_install cpupower_install gpio_install \
- hv_install firewire_install lguest_install liblockdep_install \
+ hv_install firewire_install iio_install lguest_install liblockdep_install \
perf_install selftests_install turbostat_install usb_install \
virtio_install vm_install net_install x86_energy_perf_policy_install \
tmon_install freefall_install objtool_install kvm_stat_install
diff --git a/tools/iio/Makefile b/tools/iio/Makefile
index 5581c062421a..d4d956020adf 100644
--- a/tools/iio/Makefile
+++ b/tools/iio/Makefile
@@ -1,5 +1,7 @@
include ../scripts/Makefile.include
+bindir ?= /usr/bin
+
ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
@@ -54,6 +56,12 @@ clean:
rm -rf $(OUTPUT)include/linux/iio
find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
+install: $(ALL_PROGRAMS)
+ install -d -m 755 $(DESTDIR)$(bindir); \
+ for program in $(ALL_PROGRAMS); do \
+ install $$program $(DESTDIR)$(bindir); \
+ done
+
FORCE:
-.PHONY: all clean FORCE prepare
+.PHONY: all install clean FORCE prepare
--
2.13.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/2] iio: tools: add install section
2017-07-29 0:36 ` [PATCH v1 2/2] iio: tools: add install section Andy Shevchenko
@ 2017-07-30 16:30 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2017-07-30 16:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Lars-Peter Clausen, Hartmut Knaack, Peter Meerwald-Stadler,
linux-iio, David Lechner
On Sat, 29 Jul 2017 03:36:05 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> Allow user to call install target.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This also looks good to me. Anyone else want to take
a look?
Thanks,
Jonathan
> ---
> tools/Makefile | 6 +++---
> tools/iio/Makefile | 10 +++++++++-
> 2 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/tools/Makefile b/tools/Makefile
> index 616e7722b327..f3f5f45b6355 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -93,7 +93,7 @@ kvm_stat: FORCE
> all: acpi cgroup cpupower gpio hv firewire lguest liblockdep \
> perf selftests spi turbostat usb \
> virtio vm net x86_energy_perf_policy \
> - tmon freefall objtool kvm_stat
> + tmon freefall iio objtool kvm_stat
>
> acpi_install:
> $(call descend,power/$(@:_install=),install)
> @@ -101,7 +101,7 @@ acpi_install:
> cpupower_install:
> $(call descend,power/$(@:_install=),install)
>
> -cgroup_install firewire_install gpio_install hv_install lguest_install perf_install spi_install usb_install virtio_install vm_install net_install objtool_install:
> +cgroup_install firewire_install gpio_install hv_install iio_install lguest_install perf_install spi_install usb_install virtio_install vm_install net_install objtool_install:
> $(call descend,$(@:_install=),install)
>
> liblockdep_install:
> @@ -123,7 +123,7 @@ kvm_stat_install:
> $(call descend,kvm/$(@:_install=),install)
>
> install: acpi_install cgroup_install cpupower_install gpio_install \
> - hv_install firewire_install lguest_install liblockdep_install \
> + hv_install firewire_install iio_install lguest_install liblockdep_install \
> perf_install selftests_install turbostat_install usb_install \
> virtio_install vm_install net_install x86_energy_perf_policy_install \
> tmon_install freefall_install objtool_install kvm_stat_install
> diff --git a/tools/iio/Makefile b/tools/iio/Makefile
> index 5581c062421a..d4d956020adf 100644
> --- a/tools/iio/Makefile
> +++ b/tools/iio/Makefile
> @@ -1,5 +1,7 @@
> include ../scripts/Makefile.include
>
> +bindir ?= /usr/bin
> +
> ifeq ($(srctree),)
> srctree := $(patsubst %/,%,$(dir $(CURDIR)))
> srctree := $(patsubst %/,%,$(dir $(srctree)))
> @@ -54,6 +56,12 @@ clean:
> rm -rf $(OUTPUT)include/linux/iio
> find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
>
> +install: $(ALL_PROGRAMS)
> + install -d -m 755 $(DESTDIR)$(bindir); \
> + for program in $(ALL_PROGRAMS); do \
> + install $$program $(DESTDIR)$(bindir); \
> + done
> +
> FORCE:
>
> -.PHONY: all clean FORCE prepare
> +.PHONY: all install clean FORCE prepare
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/2] iio: tools: move to tools buildsystem
2017-07-29 0:36 [PATCH v1 1/2] iio: tools: move to tools buildsystem Andy Shevchenko
2017-07-29 0:36 ` [PATCH v1 2/2] iio: tools: add install section Andy Shevchenko
@ 2017-07-30 16:28 ` Jonathan Cameron
2017-08-01 15:53 ` Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2017-07-30 16:28 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Lars-Peter Clausen, Hartmut Knaack, eter Meerwald-Stadler,
linux-iio, David Lechner
On Sat, 29 Jul 2017 03:36:04 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> There is a nice buildsystem dedicated for userspace tools in Linux kernel tree.
> Switch iio target to be built by it.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Looks very nice to me (and very very similar to gpio tools
which makes checking it is sane easy ;)
Would like this to sit on the list a little while longer
in case someone with more Make foo than me wanders by
and spots something.
Thanks,
Jonathan
> ---
> tools/iio/Build | 3 +++
> tools/iio/Makefile | 68 ++++++++++++++++++++++++++++++++++++++----------------
> 2 files changed, 51 insertions(+), 20 deletions(-)
> create mode 100644 tools/iio/Build
>
> diff --git a/tools/iio/Build b/tools/iio/Build
> new file mode 100644
> index 000000000000..f74cbda64710
> --- /dev/null
> +++ b/tools/iio/Build
> @@ -0,0 +1,3 @@
> +lsiio-y += lsiio.o iio_utils.o
> +iio_event_monitor-y += iio_event_monitor.o iio_utils.o
> +iio_generic_buffer-y += iio_generic_buffer.o iio_utils.o
> diff --git a/tools/iio/Makefile b/tools/iio/Makefile
> index 8f08e03a9a5e..5581c062421a 100644
> --- a/tools/iio/Makefile
> +++ b/tools/iio/Makefile
> @@ -1,31 +1,59 @@
> +include ../scripts/Makefile.include
> +
> +ifeq ($(srctree),)
> +srctree := $(patsubst %/,%,$(dir $(CURDIR)))
> +srctree := $(patsubst %/,%,$(dir $(srctree)))
> +endif
> +
> +# Do not use make's built-in rules
> +# (this improves performance and avoids hard-to-debug behaviour);
> +MAKEFLAGS += -r
> +
> CC = $(CROSS_COMPILE)gcc
> -CFLAGS += -Wall -g -D_GNU_SOURCE -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include
> +LD = $(CROSS_COMPILE)ld
> +CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
>
> -BINDIR=usr/bin
> -INSTALL_PROGRAM=install -m 755 -p
> -DEL_FILE=rm -f
> +ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer
> +ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
>
> -all: iio_event_monitor lsiio iio_generic_buffer
> +all: $(ALL_PROGRAMS)
>
> -iio_event_monitor: iio_event_monitor.o iio_utils.o
> +export srctree OUTPUT CC LD CFLAGS
> +include $(srctree)/tools/build/Makefile.include
>
> -lsiio: lsiio.o iio_utils.o
> +#
> +# We need the following to be outside of kernel tree
> +#
> +$(OUTPUT)include/linux/iio: ../../include/uapi/linux/iio
> + mkdir -p $(OUTPUT)include/linux/iio 2>&1 || true
> + ln -sf $(CURDIR)/../../include/uapi/linux/iio/events.h $@
> + ln -sf $(CURDIR)/../../include/uapi/linux/iio/types.h $@
>
> -iio_generic_buffer: iio_generic_buffer.o iio_utils.o
> +prepare: $(OUTPUT)include/linux/iio
>
> -%.o: %.c iio_utils.h
> +LSIIO_IN := $(OUTPUT)lsiio-in.o
> +$(LSIIO_IN): prepare FORCE
> + $(Q)$(MAKE) $(build)=lsiio
> +$(OUTPUT)lsiio: $(LSIIO_IN)
> + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
>
> -install:
> - - mkdir -p $(INSTALL_ROOT)/$(BINDIR)
> - - $(INSTALL_PROGRAM) "iio_event_monitor" "$(INSTALL_ROOT)/$(BINDIR)/iio_event_monitor"
> - - $(INSTALL_PROGRAM) "lsiio" "$(INSTALL_ROOT)/$(BINDIR)/lsiio"
> - - $(INSTALL_PROGRAM) "iio_generic_buffer" "$(INSTALL_ROOT)/$(BINDIR)/iio_generic_buffer"
> +IIO_EVENT_MONITOR_IN := $(OUTPUT)iio_event_monitor-in.o
> +$(IIO_EVENT_MONITOR_IN): prepare FORCE
> + $(Q)$(MAKE) $(build)=iio_event_monitor
> +$(OUTPUT)iio_event_monitor: $(IIO_EVENT_MONITOR_IN)
> + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
>
> -uninstall:
> - $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/iio_event_monitor"
> - $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/lsiio"
> - $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/iio_generic_buffer"
> +IIO_GENERIC_BUFFER_IN := $(OUTPUT)iio_generic_buffer-in.o
> +$(IIO_GENERIC_BUFFER_IN): prepare FORCE
> + $(Q)$(MAKE) $(build)=iio_generic_buffer
> +$(OUTPUT)iio_generic_buffer: $(IIO_GENERIC_BUFFER_IN)
> + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
>
> -.PHONY: clean
> clean:
> - rm -f *.o iio_event_monitor lsiio iio_generic_buffer
> + rm -f $(ALL_PROGRAMS)
> + rm -rf $(OUTPUT)include/linux/iio
> + find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
> +
> +FORCE:
> +
> +.PHONY: all clean FORCE prepare
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/2] iio: tools: move to tools buildsystem
2017-07-30 16:28 ` [PATCH v1 1/2] iio: tools: move to tools buildsystem Jonathan Cameron
@ 2017-08-01 15:53 ` Andy Shevchenko
2017-08-09 13:31 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2017-08-01 15:53 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Lars-Peter Clausen, Hartmut Knaack, eter Meerwald-Stadler,
linux-iio, David Lechner
On Sun, 2017-07-30 at 17:28 +0100, Jonathan Cameron wrote:
> On Sat, 29 Jul 2017 03:36:04 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > There is a nice buildsystem dedicated for userspace tools in Linux
> > kernel tree.
> > Switch iio target to be built by it.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Looks very nice to me (and very very similar to gpio tools
> which makes checking it is sane easy ;)
Thanks for review!
> Would like this to sit on the list a little while longer
> in case someone with more Make foo than me wanders by
> and spots something.
Of course!
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/2] iio: tools: move to tools buildsystem
2017-08-01 15:53 ` Andy Shevchenko
@ 2017-08-09 13:31 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2017-08-09 13:31 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Lars-Peter Clausen, Hartmut Knaack, eter Meerwald-Stadler,
linux-iio, David Lechner
On Tue, 01 Aug 2017 18:53:58 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Sun, 2017-07-30 at 17:28 +0100, Jonathan Cameron wrote:
> > On Sat, 29 Jul 2017 03:36:04 +0300
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> >
> > > There is a nice buildsystem dedicated for userspace tools in Linux
> > > kernel tree.
> > > Switch iio target to be built by it.
> > >
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
> > Looks very nice to me (and very very similar to gpio tools
> > which makes checking it is sane easy ;)
>
> Thanks for review!
>
> > Would like this to sit on the list a little while longer
> > in case someone with more Make foo than me wanders by
> > and spots something.
>
> Of course!
Long enough. Applied to the togreg branch of iio.git.
Thanks,
Jonathan
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-08-09 13:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-29 0:36 [PATCH v1 1/2] iio: tools: move to tools buildsystem Andy Shevchenko
2017-07-29 0:36 ` [PATCH v1 2/2] iio: tools: add install section Andy Shevchenko
2017-07-30 16:30 ` Jonathan Cameron
2017-07-30 16:28 ` [PATCH v1 1/2] iio: tools: move to tools buildsystem Jonathan Cameron
2017-08-01 15:53 ` Andy Shevchenko
2017-08-09 13:31 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).