All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Hartmut Knaack <knaack.h@gmx.de>,
	eter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org, David Lechner <david@lechnology.com>
Subject: Re: [PATCH v1 1/2] iio: tools: move to tools buildsystem
Date: Sun, 30 Jul 2017 17:28:54 +0100	[thread overview]
Message-ID: <20170730172854.57d1bd8b@kernel.org> (raw)
In-Reply-To: <20170729003605.73790-1-andriy.shevchenko@linux.intel.com>

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


  parent reply	other threads:[~2017-07-30 16:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Jonathan Cameron [this message]
2017-08-01 15:53   ` [PATCH v1 1/2] iio: tools: move to tools buildsystem Andy Shevchenko
2017-08-09 13:31     ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170730172854.57d1bd8b@kernel.org \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=david@lechnology.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.