linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: gpio: Find libmount with pkg-config if available
@ 2018-10-16 21:46 Daniel Díaz
  2018-12-05 21:49 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Díaz @ 2018-10-16 21:46 UTC (permalink / raw)
  To: shuah, linux-kselftest
  Cc: Daniel Díaz, Bamvor Jian Zhang, Bartosz Golaszewski,
	open list:GPIO MOCKUP DRIVER, open list

If pkg-config is available, use it to define the CFLAGS and
LDLIBS needed for libmount; else, use the current hard-coded
paths and options.

Using pkg-config is very helpful for cross-compilation
environments, and is sometimes readily available on developer
boxes to ensure we get the right compiler/linker options for
the given package.

Signed-off-by: Daniel Díaz <daniel.diaz@linaro.org>
---
 tools/testing/selftests/gpio/Makefile | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 46648427d537..f22b22aef7bf 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -1,7 +1,13 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
-LDLIBS += -lmount -I/usr/include/libmount
+MOUNT_CFLAGS := $(shell pkg-config --cflags mount 2>/dev/null)
+MOUNT_LDLIBS := $(shell pkg-config --libs mount 2>/dev/null)
+ifeq ($(MOUNT_LDLIBS),)
+MOUNT_LDLIBS := -lmount -I/usr/include/libmount
+endif
+
+CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ $(MOUNT_CFLAGS)
+LDLIBS += $(MOUNT_LDLIBS)
 
 TEST_PROGS := gpio-mockup.sh
 TEST_FILES := gpio-mockup-sysfs.sh
-- 
2.17.1


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

* Re: [PATCH] selftests: gpio: Find libmount with pkg-config if available
  2018-10-16 21:46 [PATCH] selftests: gpio: Find libmount with pkg-config if available Daniel Díaz
@ 2018-12-05 21:49 ` Linus Walleij
  2018-12-05 23:15   ` Anders Roxell
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2018-12-05 21:49 UTC (permalink / raw)
  To: daniel.diaz, Anders Roxell, shuah
  Cc: linux-kselftest, Bamvor Jian Zhang, Bartosz Golaszewski,
	open list:GPIO SUBSYSTEM, linux-kernel

Sorry for top-posting,

I don't understand the selftest environment very well so I do not know
if this is the right thing to do.

I can merge the patch through the GPIO tree but I need a nod from
someone wise, like Shuah Khan or Anders Roxell (Anders has been
using the GPIO selftests) that this is the direction we want to go.

Yours,
Linus Walleij

On Tue, Oct 16, 2018 at 11:47 PM Daniel Díaz <daniel.diaz@linaro.org> wrote:

> If pkg-config is available, use it to define the CFLAGS and
> LDLIBS needed for libmount; else, use the current hard-coded
> paths and options.
>
> Using pkg-config is very helpful for cross-compilation
> environments, and is sometimes readily available on developer
> boxes to ensure we get the right compiler/linker options for
> the given package.
>
> Signed-off-by: Daniel Díaz <daniel.diaz@linaro.org>
> ---
>  tools/testing/selftests/gpio/Makefile | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
> index 46648427d537..f22b22aef7bf 100644
> --- a/tools/testing/selftests/gpio/Makefile
> +++ b/tools/testing/selftests/gpio/Makefile
> @@ -1,7 +1,13 @@
>  # SPDX-License-Identifier: GPL-2.0
>
> -CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
> -LDLIBS += -lmount -I/usr/include/libmount
> +MOUNT_CFLAGS := $(shell pkg-config --cflags mount 2>/dev/null)
> +MOUNT_LDLIBS := $(shell pkg-config --libs mount 2>/dev/null)
> +ifeq ($(MOUNT_LDLIBS),)
> +MOUNT_LDLIBS := -lmount -I/usr/include/libmount
> +endif
> +
> +CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ $(MOUNT_CFLAGS)
> +LDLIBS += $(MOUNT_LDLIBS)
>
>  TEST_PROGS := gpio-mockup.sh
>  TEST_FILES := gpio-mockup-sysfs.sh
> --
> 2.17.1
>

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

* Re: [PATCH] selftests: gpio: Find libmount with pkg-config if available
  2018-12-05 21:49 ` Linus Walleij
@ 2018-12-05 23:15   ` Anders Roxell
  2018-12-05 23:21     ` shuah
  0 siblings, 1 reply; 4+ messages in thread
From: Anders Roxell @ 2018-12-05 23:15 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Daniel Díaz, Shuah Khan,
	open list:KERNEL SELFTEST FRAMEWORK, Bamvor Zhang, brgl,
	linux-gpio, Linux Kernel Mailing List

On Wed, 5 Dec 2018 at 22:50, Linus Walleij <linus.walleij@linaro.org> wrote:
>
> Sorry for top-posting,
>
> I don't understand the selftest environment very well so I do not know
> if this is the right thing to do.
>
> I can merge the patch through the GPIO tree but I need a nod from
> someone wise, like Shuah Khan or Anders Roxell (Anders has been
> using the GPIO selftests) that this is the direction we want to go.

Yes this makes sense and its already in linux-next.

Cheers,
Anders

>
> Yours,
> Linus Walleij
>
> On Tue, Oct 16, 2018 at 11:47 PM Daniel Díaz <daniel.diaz@linaro.org> wrote:
>
> > If pkg-config is available, use it to define the CFLAGS and
> > LDLIBS needed for libmount; else, use the current hard-coded
> > paths and options.
> >
> > Using pkg-config is very helpful for cross-compilation
> > environments, and is sometimes readily available on developer
> > boxes to ensure we get the right compiler/linker options for
> > the given package.
> >
> > Signed-off-by: Daniel Díaz <daniel.diaz@linaro.org>
> > ---
> >  tools/testing/selftests/gpio/Makefile | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
> > index 46648427d537..f22b22aef7bf 100644
> > --- a/tools/testing/selftests/gpio/Makefile
> > +++ b/tools/testing/selftests/gpio/Makefile
> > @@ -1,7 +1,13 @@
> >  # SPDX-License-Identifier: GPL-2.0
> >
> > -CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
> > -LDLIBS += -lmount -I/usr/include/libmount
> > +MOUNT_CFLAGS := $(shell pkg-config --cflags mount 2>/dev/null)
> > +MOUNT_LDLIBS := $(shell pkg-config --libs mount 2>/dev/null)
> > +ifeq ($(MOUNT_LDLIBS),)
> > +MOUNT_LDLIBS := -lmount -I/usr/include/libmount
> > +endif
> > +
> > +CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ $(MOUNT_CFLAGS)
> > +LDLIBS += $(MOUNT_LDLIBS)
> >
> >  TEST_PROGS := gpio-mockup.sh
> >  TEST_FILES := gpio-mockup-sysfs.sh
> > --
> > 2.17.1
> >

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

* Re: [PATCH] selftests: gpio: Find libmount with pkg-config if available
  2018-12-05 23:15   ` Anders Roxell
@ 2018-12-05 23:21     ` shuah
  0 siblings, 0 replies; 4+ messages in thread
From: shuah @ 2018-12-05 23:21 UTC (permalink / raw)
  To: Anders Roxell, Linus Walleij
  Cc: Daniel Díaz, open list:KERNEL SELFTEST FRAMEWORK,
	Bamvor Zhang, brgl, linux-gpio, Linux Kernel Mailing List, shuah

On 12/5/18 4:15 PM, Anders Roxell wrote:
> On Wed, 5 Dec 2018 at 22:50, Linus Walleij <linus.walleij@linaro.org> wrote:
>>
>> Sorry for top-posting,
>>
>> I don't understand the selftest environment very well so I do not know
>> if this is the right thing to do.
>>
>> I can merge the patch through the GPIO tree but I need a nod from
>> someone wise, like Shuah Khan or Anders Roxell (Anders has been
>> using the GPIO selftests) that this is the direction we want to go.
> 
> Yes this makes sense and its already in linux-next.
> 

Linus,

Great. I pulled this in last week into kselftest next for 4.21-rc1 
thinking that this is a good direction.

thanks,
-- Shuah


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

end of thread, other threads:[~2018-12-05 23:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-16 21:46 [PATCH] selftests: gpio: Find libmount with pkg-config if available Daniel Díaz
2018-12-05 21:49 ` Linus Walleij
2018-12-05 23:15   ` Anders Roxell
2018-12-05 23:21     ` shuah

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