linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] tools/gpio: switch to tools buildsystem
@ 2016-06-19 20:41 Andy Shevchenko
  2016-06-19 20:41 ` [PATCH v3 1/2] tools/gpio: move " Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2016-06-19 20:41 UTC (permalink / raw)
  To: Alexandre Courbot, Linus Walleij, linux-gpio, Mika Westerberg
  Cc: Andy Shevchenko

Current environment is not allowed to easily build the tools.
Move to tools buildsystem to allow user build gpio tools using only existing
kernel sources. Besides that support O=/path/to/build/dir option.

In v3:
- fold patch 1 & 2 (Alexandre Courbot)
- add CROSS_COMPILE prefix to ld (Alexandre Courbot)
- move definition of bindir to last patch

In v2:
- remove $(Q) for now for shell commands
- add cover letter

Andy Shevchenko (2):
  tools/gpio: move to tools buildsystem
  tools/gpio: add install section

 tools/Makefile      |  7 ++---
 tools/gpio/Build    |  3 +++
 tools/gpio/Makefile | 77 +++++++++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 76 insertions(+), 11 deletions(-)
 create mode 100644 tools/gpio/Build

-- 
2.8.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/2] tools/gpio: move to tools buildsystem
  2016-06-19 20:41 [PATCH v3 0/2] tools/gpio: switch to tools buildsystem Andy Shevchenko
@ 2016-06-19 20:41 ` Andy Shevchenko
  2016-06-19 20:41 ` [PATCH v3 2/2] tools/gpio: add install section Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2016-06-19 20:41 UTC (permalink / raw)
  To: Alexandre Courbot, Linus Walleij, linux-gpio, Mika Westerberg
  Cc: Andy Shevchenko

There is a nice buildsystem dedicated for userspace tools in Linux kernel tree.
Switch gpio target to be built by it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 tools/gpio/Build    |  3 +++
 tools/gpio/Makefile | 69 ++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 64 insertions(+), 8 deletions(-)
 create mode 100644 tools/gpio/Build

diff --git a/tools/gpio/Build b/tools/gpio/Build
new file mode 100644
index 0000000..620c1937
--- /dev/null
+++ b/tools/gpio/Build
@@ -0,0 +1,3 @@
+lsgpio-y += lsgpio.o gpio-utils.o
+gpio-hammer-y += gpio-hammer.o gpio-utils.o
+gpio-event-mon-y += gpio-event-mon.o gpio-utils.o
diff --git a/tools/gpio/Makefile b/tools/gpio/Makefile
index 619314f..5a82f15 100644
--- a/tools/gpio/Makefile
+++ b/tools/gpio/Makefile
@@ -1,14 +1,67 @@
+include ../scripts/Makefile.include
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(shell pwd)))
+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 += -O2 -Wall -g -D_GNU_SOURCE
+LD = $(CROSS_COMPILE)ld
+CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
+
+ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon
+ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
+
+all: $(ALL_PROGRAMS)
 
-all: lsgpio gpio-hammer gpio-event-mon
+export srctree OUTPUT CC LD CFLAGS
+include $(srctree)/tools/build/Makefile.include
 
-lsgpio: lsgpio.o gpio-utils.o
-gpio-hammer: gpio-hammer.o gpio-utils.o
-gpio-event-mon: gpio-event-mon.o gpio-utils.o
+#
+# We need the following to be outside of kernel tree
+#
+$(OUTPUT)include/linux/gpio.h: ../../include/uapi/linux/gpio.h
+	mkdir -p $(OUTPUT)include/linux 2>&1 || true
+	ln -sf $(CURDIR)/../../include/uapi/linux/gpio.h $@
 
-%.o: %.c gpio-utils.h
+prepare: $(OUTPUT)include/linux/gpio.h
+
+#
+# lsgpio
+#
+LSGPIO_IN := $(OUTPUT)lsgpio-in.o
+$(LSGPIO_IN): prepare FORCE
+	$(Q)$(MAKE) $(build)=lsgpio
+$(OUTPUT)lsgpio: $(LSGPIO_IN)
+	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
+
+#
+# gpio-hammer
+#
+GPIO_HAMMER_IN := $(OUTPUT)gpio-hammer-in.o
+$(GPIO_HAMMER_IN): prepare FORCE
+	$(Q)$(MAKE) $(build)=gpio-hammer
+$(OUTPUT)gpio-hammer: $(GPIO_HAMMER_IN)
+	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
+
+#
+# gpio-event-mon
+#
+GPIO_EVENT_MON_IN := $(OUTPUT)gpio-event-mon-in.o
+$(GPIO_EVENT_MON_IN): prepare FORCE
+	$(Q)$(MAKE) $(build)=gpio-event-mon
+$(OUTPUT)gpio-event-mon: $(GPIO_EVENT_MON_IN)
+	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
 
-.PHONY: clean
 clean:
-	rm -f *.o lsgpio gpio-hammer gpio-event-mon
+	rm -f $(ALL_PROGRAMS)
+	rm -f $(OUTPUT)include/linux/gpio.h
+	find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
+
+FORCE:
+
+.PHONY: all clean FORCE prepare
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/2] tools/gpio: add install section
  2016-06-19 20:41 [PATCH v3 0/2] tools/gpio: switch to tools buildsystem Andy Shevchenko
  2016-06-19 20:41 ` [PATCH v3 1/2] tools/gpio: move " Andy Shevchenko
@ 2016-06-19 20:41 ` Andy Shevchenko
  2016-06-20 12:17 ` [PATCH v3 0/2] tools/gpio: switch to tools buildsystem Alexandre Courbot
  2016-06-23  7:59 ` Linus Walleij
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2016-06-19 20:41 UTC (permalink / raw)
  To: Alexandre Courbot, Linus Walleij, linux-gpio, Mika Westerberg
  Cc: Andy Shevchenko

Allow user to call install target.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 tools/Makefile      |  7 ++++---
 tools/gpio/Makefile | 10 +++++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/tools/Makefile b/tools/Makefile
index f10b64d8..daa8fb3 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -85,7 +85,7 @@ tmon: FORCE
 freefall: FORCE
 	$(call descend,laptop/$@)
 
-all: acpi cgroup cpupower hv firewire lguest \
+all: acpi cgroup cpupower gpio hv firewire lguest \
 		perf selftests turbostat usb \
 		virtio vm net x86_energy_perf_policy \
 		tmon freefall objtool
@@ -96,7 +96,7 @@ acpi_install:
 cpupower_install:
 	$(call descend,power/$(@:_install=),install)
 
-cgroup_install firewire_install hv_install lguest_install perf_install usb_install virtio_install vm_install net_install objtool_install:
+cgroup_install firewire_install gpio_install hv_install lguest_install perf_install usb_install virtio_install vm_install net_install objtool_install:
 	$(call descend,$(@:_install=),install)
 
 selftests_install:
@@ -114,7 +114,8 @@ freefall_install:
 kvm_stat_install:
 	$(call descend,kvm/$(@:_install=),install)
 
-install: acpi_install cgroup_install cpupower_install hv_install firewire_install lguest_install \
+install: acpi_install cgroup_install cpupower_install gpio_install \
+		hv_install firewire_install lguest_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/gpio/Makefile b/tools/gpio/Makefile
index 5a82f15..250a891 100644
--- a/tools/gpio/Makefile
+++ b/tools/gpio/Makefile
@@ -1,5 +1,7 @@
 include ../scripts/Makefile.include
 
+bindir ?= /usr/bin
+
 ifeq ($(srctree),)
 srctree := $(patsubst %/,%,$(dir $(shell pwd)))
 srctree := $(patsubst %/,%,$(dir $(srctree)))
@@ -62,6 +64,12 @@ clean:
 	rm -f $(OUTPUT)include/linux/gpio.h
 	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.8.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 0/2] tools/gpio: switch to tools buildsystem
  2016-06-19 20:41 [PATCH v3 0/2] tools/gpio: switch to tools buildsystem Andy Shevchenko
  2016-06-19 20:41 ` [PATCH v3 1/2] tools/gpio: move " Andy Shevchenko
  2016-06-19 20:41 ` [PATCH v3 2/2] tools/gpio: add install section Andy Shevchenko
@ 2016-06-20 12:17 ` Alexandre Courbot
  2016-06-23  7:59 ` Linus Walleij
  3 siblings, 0 replies; 5+ messages in thread
From: Alexandre Courbot @ 2016-06-20 12:17 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, linux-gpio@vger.kernel.org, Mika Westerberg

On Mon, Jun 20, 2016 at 5:41 AM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Current environment is not allowed to easily build the tools.
> Move to tools buildsystem to allow user build gpio tools using only existing
> kernel sources. Besides that support O=/path/to/build/dir option.

Cross-compilation working like a charm now!

Both patches,

Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Alexandre Courbot <acourbot@nvidia.com>

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 0/2] tools/gpio: switch to tools buildsystem
  2016-06-19 20:41 [PATCH v3 0/2] tools/gpio: switch to tools buildsystem Andy Shevchenko
                   ` (2 preceding siblings ...)
  2016-06-20 12:17 ` [PATCH v3 0/2] tools/gpio: switch to tools buildsystem Alexandre Courbot
@ 2016-06-23  7:59 ` Linus Walleij
  3 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2016-06-23  7:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, Mika Westerberg

On Sun, Jun 19, 2016 at 10:41 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Current environment is not allowed to easily build the tools.
> Move to tools buildsystem to allow user build gpio tools using only existing
> kernel sources. Besides that support O=/path/to/build/dir option.
>
> In v3:
> - fold patch 1 & 2 (Alexandre Courbot)
> - add CROSS_COMPILE prefix to ld (Alexandre Courbot)
> - move definition of bindir to last patch

Both patches applied with Alexandre's ACK/Test tags.
Excellent work, thank you for fixing up my uglyhacks.

I think my tools were inspired by tools/iio, now that needs
fixing too...

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-23  7:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-19 20:41 [PATCH v3 0/2] tools/gpio: switch to tools buildsystem Andy Shevchenko
2016-06-19 20:41 ` [PATCH v3 1/2] tools/gpio: move " Andy Shevchenko
2016-06-19 20:41 ` [PATCH v3 2/2] tools/gpio: add install section Andy Shevchenko
2016-06-20 12:17 ` [PATCH v3 0/2] tools/gpio: switch to tools buildsystem Alexandre Courbot
2016-06-23  7:59 ` Linus Walleij

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).