* [PATCH v2 1/3] tools/gpio: remove old Makefile
2016-06-18 15:24 [PATCH v2 0/3] tools/gpio: switch to tools buildsystem Andy Shevchenko
@ 2016-06-18 15:24 ` Andy Shevchenko
2016-06-18 15:24 ` [PATCH v2 2/3] tools/gpio: move to tools buildsystem Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2016-06-18 15:24 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot, linux-gpio, Mika Westerberg
Cc: Andy Shevchenko
Prepare to switch to tools build system, i.e. remove Makefile completely. There
is no much sense to keep it since it will be rewritten (almost) completely.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
tools/gpio/Makefile | 14 --------------
1 file changed, 14 deletions(-)
delete mode 100644 tools/gpio/Makefile
diff --git a/tools/gpio/Makefile b/tools/gpio/Makefile
deleted file mode 100644
index 619314f..0000000
--- a/tools/gpio/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-CC = $(CROSS_COMPILE)gcc
-CFLAGS += -O2 -Wall -g -D_GNU_SOURCE
-
-all: lsgpio gpio-hammer gpio-event-mon
-
-lsgpio: lsgpio.o gpio-utils.o
-gpio-hammer: gpio-hammer.o gpio-utils.o
-gpio-event-mon: gpio-event-mon.o gpio-utils.o
-
-%.o: %.c gpio-utils.h
-
-.PHONY: clean
-clean:
- rm -f *.o lsgpio gpio-hammer gpio-event-mon
--
2.8.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] tools/gpio: move to tools buildsystem
2016-06-18 15:24 [PATCH v2 0/3] tools/gpio: switch to tools buildsystem Andy Shevchenko
2016-06-18 15:24 ` [PATCH v2 1/3] tools/gpio: remove old Makefile Andy Shevchenko
@ 2016-06-18 15:24 ` Andy Shevchenko
2016-06-18 15:24 ` [PATCH v2 3/3] tools/gpio: add install section Andy Shevchenko
2016-06-19 13:07 ` [PATCH v2 0/3] tools/gpio: switch to tools buildsystem Alexandre Courbot
3 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2016-06-18 15:24 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot, 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 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+)
create mode 100644 tools/gpio/Build
create mode 100644 tools/gpio/Makefile
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
new file mode 100644
index 0000000..d151b42
--- /dev/null
+++ b/tools/gpio/Makefile
@@ -0,0 +1,77 @@
+include ../scripts/Makefile.include
+
+bindir ?= /usr/bin
+
+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 -I$(OUTPUT)include
+
+ALL_TARGETS := lsgpio gpio-hammer gpio-event-mon
+ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
+
+all: $(ALL_PROGRAMS)
+
+export srctree OUTPUT CC LD CFLAGS
+include $(srctree)/tools/build/Makefile.include
+
+#
+# If a target does not match any of the later rules then prefix it by $(OUTPUT)
+# This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.
+#
+ifneq ($(OUTPUT),)
+%.o: $(OUTPUT)%.o
+ @echo " # Redirected target $@ => $(OUTPUT)$@"
+endif
+
+#
+# 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 $@
+
+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 $@
+
+clean:
+ 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] 7+ messages in thread
* [PATCH v2 3/3] tools/gpio: add install section
2016-06-18 15:24 [PATCH v2 0/3] tools/gpio: switch to tools buildsystem Andy Shevchenko
2016-06-18 15:24 ` [PATCH v2 1/3] tools/gpio: remove old Makefile Andy Shevchenko
2016-06-18 15:24 ` [PATCH v2 2/3] tools/gpio: move to tools buildsystem Andy Shevchenko
@ 2016-06-18 15:24 ` Andy Shevchenko
2016-06-19 13:07 ` [PATCH v2 0/3] tools/gpio: switch to tools buildsystem Alexandre Courbot
3 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2016-06-18 15:24 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot, 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 | 8 +++++++-
2 files changed, 11 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 d151b42..2f9fd55 100644
--- a/tools/gpio/Makefile
+++ b/tools/gpio/Makefile
@@ -72,6 +72,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] 7+ messages in thread
* Re: [PATCH v2 0/3] tools/gpio: switch to tools buildsystem
2016-06-18 15:24 [PATCH v2 0/3] tools/gpio: switch to tools buildsystem Andy Shevchenko
` (2 preceding siblings ...)
2016-06-18 15:24 ` [PATCH v2 3/3] tools/gpio: add install section Andy Shevchenko
@ 2016-06-19 13:07 ` Alexandre Courbot
2016-06-19 13:52 ` Andy Shevchenko
3 siblings, 1 reply; 7+ messages in thread
From: Alexandre Courbot @ 2016-06-19 13:07 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Linus Walleij, linux-gpio@vger.kernel.org, Mika Westerberg
On Sun, Jun 19, 2016 at 12:24 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.
Very good idea. I just have a few issues with the current patchset:
1) I think patch 1 and 2 should be merged, otherwise we would have one
commit where the GPIO tools are not available anymore
2) When trying to cross-compile the tools, I am hitting the following error:
arm-linux-gnueabihf-gcc -Wp,-MD,./.lsgpio.o.d,-MT,lsgpio.o -O2 -Wall
-g -D_GNU_SOURCE -Iinclude -D"BUILD_STR(s)=#s" -c -o lsgpio.o
lsgpio.c
arm-linux-gnueabihf-gcc -Wp,-MD,./.gpio-utils.o.d,-MT,gpio-utils.o
-O2 -Wall -g -D_GNU_SOURCE -Iinclude -D"BUILD_STR(s)=#s" -c -o
gpio-utils.o gpio-utils.c
ld -r -o lsgpio-in.o lsgpio.o gpio-utils.o
lsgpio.o: error adding symbols: File in wrong format
Looks like the host linker is invoked instead of the target one.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/3] tools/gpio: switch to tools buildsystem
2016-06-19 13:07 ` [PATCH v2 0/3] tools/gpio: switch to tools buildsystem Alexandre Courbot
@ 2016-06-19 13:52 ` Andy Shevchenko
2016-06-19 14:00 ` Alexandre Courbot
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2016-06-19 13:52 UTC (permalink / raw)
To: Alexandre Courbot
Cc: Linus Walleij, linux-gpio@vger.kernel.org, Mika Westerberg
On Sun, 2016-06-19 at 22:07 +0900, Alexandre Courbot wrote:
> On Sun, Jun 19, 2016 at 12:24 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.
>
> Very good idea. I just have a few issues with the current patchset:
>
> 1) I think patch 1 and 2 should be merged, otherwise we would have one
> commit where the GPIO tools are not available anymore
No objection!
> 2) When trying to cross-compile the tools, I am hitting the following
> error:
>
> arm-linux-gnueabihf-gcc -Wp,-MD,./.lsgpio.o.d,-MT,lsgpio.o -O2 -Wall
> -g -D_GNU_SOURCE -Iinclude -D"BUILD_STR(s)=#s" -c -o lsgpio.o
> lsgpio.c
> arm-linux-gnueabihf-gcc -Wp,-MD,./.gpio-utils.o.d,-MT,gpio-utils.o
> -O2 -Wall -g -D_GNU_SOURCE -Iinclude -D"BUILD_STR(s)=#s" -c -o
> gpio-utils.o gpio-utils.c
> ld -r -o lsgpio-in.o lsgpio.o gpio-utils.o
> lsgpio.o: error adding symbols: File in wrong format
>
> Looks like the host linker is invoked instead of the target one.
Can you try to add
LD = $(CROSS_COMPILE)ld
into Makefile and re-run?
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/3] tools/gpio: switch to tools buildsystem
2016-06-19 13:52 ` Andy Shevchenko
@ 2016-06-19 14:00 ` Alexandre Courbot
0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Courbot @ 2016-06-19 14:00 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Linus Walleij, linux-gpio@vger.kernel.org, Mika Westerberg
On Sun, Jun 19, 2016 at 10:52 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Sun, 2016-06-19 at 22:07 +0900, Alexandre Courbot wrote:
>> On Sun, Jun 19, 2016 at 12:24 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.
>>
>> Very good idea. I just have a few issues with the current patchset:
>>
>> 1) I think patch 1 and 2 should be merged, otherwise we would have one
>> commit where the GPIO tools are not available anymore
>
> No objection!
>
>> 2) When trying to cross-compile the tools, I am hitting the following
>> error:
>>
>> arm-linux-gnueabihf-gcc -Wp,-MD,./.lsgpio.o.d,-MT,lsgpio.o -O2 -Wall
>> -g -D_GNU_SOURCE -Iinclude -D"BUILD_STR(s)=#s" -c -o lsgpio.o
>> lsgpio.c
>> arm-linux-gnueabihf-gcc -Wp,-MD,./.gpio-utils.o.d,-MT,gpio-utils.o
>> -O2 -Wall -g -D_GNU_SOURCE -Iinclude -D"BUILD_STR(s)=#s" -c -o
>> gpio-utils.o gpio-utils.c
>> ld -r -o lsgpio-in.o lsgpio.o gpio-utils.o
>> lsgpio.o: error adding symbols: File in wrong format
>>
>> Looks like the host linker is invoked instead of the target one.
>
> Can you try to add
>
> LD = $(CROSS_COMPILE)ld
>
> into Makefile and re-run?
That fixes it, thanks! Will try again with the next revision.
This series makes me happy, I never found how to cross-compile the
GPIO tools with the previous Makefile...
^ permalink raw reply [flat|nested] 7+ messages in thread