Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1608359 > unrolled thread

[PATCH] selftests: gpio: fix Makefile

Started byFathi Boudra <fathi.boudra@linaro.org>
First post2017-03-24 13:00 +0100
Last post2017-03-28 06:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] selftests: gpio: fix Makefile Fathi Boudra <fathi.boudra@linaro.org> - 2017-03-24 13:00 +0100
    Re: [PATCH] selftests: gpio: fix Makefile Michael Ellerman <mpe@ellerman.id.au> - 2017-03-28 05:10 +0200
      Re: [PATCH] selftests: gpio: fix Makefile Fathi Boudra <fathi.boudra@linaro.org> - 2017-03-28 06:20 +0200

#1608359 — [PATCH] selftests: gpio: fix Makefile

FromFathi Boudra <fathi.boudra@linaro.org>
Date2017-03-24 13:00 +0100
Subject[PATCH] selftests: gpio: fix Makefile
Message-ID<tow2S-10z-9@gated-at.bofh.it>
* Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
  figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.

* Fix the clean target to clean up also gpio-utils.

* Fix gpio-mockup-chardev installation by using TEST_PROGS_EXTENDED
  instead of BINARIES which is not supported by the top-level lib.mk.

* Remove dependency to headers_install as we can simply use gpio.h from
  user space API directly.

* Improve readibility:
  - introduce GPIODIR/GPIOOBJ variables
  - split CFLAGS on multiple lines

Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
---
 tools/testing/selftests/gpio/Makefile | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 205e4d10e085..714f1f7df04d 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -1,23 +1,24 @@
+CFLAGS += -O2 -g -std=gnu99 -Wall
+CFLAGS += -I../../../../include/uapi/ -I../../../../include/
+CFLAGS += $(shell pkg-config --cflags mount)
+LDLIBS += $(shell pkg-config --libs mount)
 
 TEST_PROGS := gpio-mockup.sh
-TEST_FILES := gpio-mockup-sysfs.sh $(BINARIES)
-BINARIES := gpio-mockup-chardev
+TEST_PROGS_EXTENDED := gpio-mockup-chardev
+TEST_FILES := gpio-mockup-sysfs.sh
+
+GPIODIR := ../../../gpio
+GPIOOBJ := gpio-utils.o
 
 include ../lib.mk
 
-all: $(BINARIES)
+all: $(TEST_PROGS_EXTENDED)
 
 clean:
-	$(RM) $(BINARIES)
-
-CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
-LDLIBS += -lmount -I/usr/include/libmount
-
-$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h
-
-../../../gpio/gpio-utils.o:
-	make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+	$(RM) $(TEST_PROGS_EXTENDED)
+	$(MAKE) -C $(GPIODIR) clean
 
-../../../../usr/include/linux/gpio.h:
-	make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/
+$(TEST_PROGS_EXTENDED): $(GPIODIR)/$(GPIOOBJ)
 
+$(GPIODIR)/$(GPIOOBJ):
+	$(MAKE) -C $(GPIODIR)
-- 
2.11.0

[toc] | [next] | [standalone]


#1610273

FromMichael Ellerman <mpe@ellerman.id.au>
Date2017-03-28 05:10 +0200
Message-ID<tpPGa-1lb-7@gated-at.bofh.it>
In reply to#1608359
Fathi Boudra <fathi.boudra@linaro.org> writes:
> diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
> index 205e4d10e085..714f1f7df04d 100644
> --- a/tools/testing/selftests/gpio/Makefile
> +++ b/tools/testing/selftests/gpio/Makefile
> @@ -1,23 +1,24 @@
> +CFLAGS += -O2 -g -std=gnu99 -Wall
> +CFLAGS += -I../../../../include/uapi/ -I../../../../include/

Those are kernel headers, they *might* work in userspace but they're not
designed to.

Use the exported headers:

CFLAGS += -I../../../../usr/include


If they're not there, then the user can install them, or fall back to
the system headers.

> +CFLAGS += $(shell pkg-config --cflags mount)
> +LDLIBS += $(shell pkg-config --libs mount)

What if pkg-config isn't installed?

cheers

[toc] | [prev] | [next] | [standalone]


#1610283

FromFathi Boudra <fathi.boudra@linaro.org>
Date2017-03-28 06:20 +0200
Message-ID<tpQLT-27u-3@gated-at.bofh.it>
In reply to#1610273
On 28 March 2017 at 06:00, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Fathi Boudra <fathi.boudra@linaro.org> writes:
>> diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
>> index 205e4d10e085..714f1f7df04d 100644
>> --- a/tools/testing/selftests/gpio/Makefile
>> +++ b/tools/testing/selftests/gpio/Makefile
>> @@ -1,23 +1,24 @@
>> +CFLAGS += -O2 -g -std=gnu99 -Wall
>> +CFLAGS += -I../../../../include/uapi/ -I../../../../include/
>
> Those are kernel headers, they *might* work in userspace but they're not
> designed to.

except some tests are using uapi and some others are using the
generated headers inconsistently, so it looks like using uapi directly
is allowed. Do you suggest to fix the tests to only use the exported
headers consistently across selftests and add the dependency to
headers_install when necessary?

> Use the exported headers:
>
> CFLAGS += -I../../../../usr/include
>
>
> If they're not there, then the user can install them, or fall back to
> the system headers.
>
>> +CFLAGS += $(shell pkg-config --cflags mount)
>> +LDLIBS += $(shell pkg-config --libs mount)
>
> What if pkg-config isn't installed?

it gives an error (command not found) and gpio test will fail to build
because it won't be able to find the headers or link to libmount
library.

> cheers

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web