linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS
@ 2017-06-29  6:58 Fathi Boudra
  2017-06-29  9:01 ` Michael Ellerman
  0 siblings, 1 reply; 8+ messages in thread
From: Fathi Boudra @ 2017-06-29  6:58 UTC (permalink / raw)
  To: linux-kselftest, Shuah Khan
  Cc: linux-kernel, Bamvor Jian Zhang, Michael Ellerman, Fathi Boudra

Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.

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.

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

diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 298929df97e6..11eed0cdec2a 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -17,8 +17,8 @@ override define CLEAN
 	$(RM) -r $(EXTRA_DIRS)
 endef
 
-CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
-LDLIBS += -lmount -I/usr/include/libmount
+CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ $(shell pkg-config --cflags mount)
+LDLIBS += $(shell pkg-config --libs mount)
 
 $(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h
 
-- 
2.13.0

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

* Re: [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS
  2017-06-29  6:58 [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS Fathi Boudra
@ 2017-06-29  9:01 ` Michael Ellerman
  2017-06-29 11:39   ` Fathi Boudra
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Ellerman @ 2017-06-29  9:01 UTC (permalink / raw)
  To: Fathi Boudra, linux-kselftest, Shuah Khan
  Cc: linux-kernel, Bamvor Jian Zhang, Fathi Boudra

Fathi Boudra <fathi.boudra@linaro.org> writes:

> Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
> figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.

Can you explain how it fixes the values for cross-compilation?

cheers

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

* Re: [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS
  2017-06-29  9:01 ` Michael Ellerman
@ 2017-06-29 11:39   ` Fathi Boudra
  2017-06-30  2:20     ` Bamvor Zhang Jian
  2017-06-30 11:01     ` Michael Ellerman
  0 siblings, 2 replies; 8+ messages in thread
From: Fathi Boudra @ 2017-06-29 11:39 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linux-kselftest, Shuah Khan, linux-kernel, Bamvor Jian Zhang

On 29 June 2017 at 12:01, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Fathi Boudra <fathi.boudra@linaro.org> writes:
>
>> Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
>> figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.
>
> Can you explain how it fixes the values for cross-compilation?

When pkg-config is invoked in a cross-build environment, it will
return your sysroot headers path instead of the hardcoded
-I/usr/include/libmount

For example in my oe environment, when I invoke "pkg-config --cflags
mount", it returns:
-I/build/tmp-rpb-glibc/sysroots/hikey/usr/include/libmount

> cheers
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kselftest" 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] 8+ messages in thread

* Re: [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS
  2017-06-29 11:39   ` Fathi Boudra
@ 2017-06-30  2:20     ` Bamvor Zhang Jian
  2017-06-30  5:53       ` Fathi Boudra
  2017-06-30 11:01     ` Michael Ellerman
  1 sibling, 1 reply; 8+ messages in thread
From: Bamvor Zhang Jian @ 2017-06-30  2:20 UTC (permalink / raw)
  To: Fathi Boudra; +Cc: Michael Ellerman, linux-kselftest, Shuah Khan, linux-kernel

On 29 June 2017 at 19:39, Fathi Boudra <fathi.boudra@linaro.org> wrote:
> On 29 June 2017 at 12:01, Michael Ellerman <mpe@ellerman.id.au> wrote:
>> Fathi Boudra <fathi.boudra@linaro.org> writes:
>>
>>> Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
>>> figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.
>>
>> Can you explain how it fixes the values for cross-compilation?
>
> When pkg-config is invoked in a cross-build environment, it will
> return your sysroot headers path instead of the hardcoded
> -I/usr/include/libmount
>
> For example in my oe environment, when I invoke "pkg-config --cflags
> mount", it returns:
> -I/build/tmp-rpb-glibc/sysroots/hikey/usr/include/libmount
I suppose we could also pass the extra CFLAGS and LDFLAGS directly to
make it work. correct?

Regards

Bamvor
>
>> cheers
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kselftest" 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] 8+ messages in thread

* Re: [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS
  2017-06-30  2:20     ` Bamvor Zhang Jian
@ 2017-06-30  5:53       ` Fathi Boudra
  2017-07-01  1:48         ` Michael Ellerman
  0 siblings, 1 reply; 8+ messages in thread
From: Fathi Boudra @ 2017-06-30  5:53 UTC (permalink / raw)
  To: Bamvor Zhang Jian
  Cc: Michael Ellerman, linux-kselftest, Shuah Khan, linux-kernel

On 30 June 2017 at 05:20, Bamvor Zhang Jian <bamvor.zhangjian@linaro.org> wrote:
> On 29 June 2017 at 19:39, Fathi Boudra <fathi.boudra@linaro.org> wrote:
>> On 29 June 2017 at 12:01, Michael Ellerman <mpe@ellerman.id.au> wrote:
>>> Fathi Boudra <fathi.boudra@linaro.org> writes:
>>>
>>>> Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
>>>> figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.
>>>
>>> Can you explain how it fixes the values for cross-compilation?
>>
>> When pkg-config is invoked in a cross-build environment, it will
>> return your sysroot headers path instead of the hardcoded
>> -I/usr/include/libmount
>>
>> For example in my oe environment, when I invoke "pkg-config --cflags
>> mount", it returns:
>> -I/build/tmp-rpb-glibc/sysroots/hikey/usr/include/libmount
> I suppose we could also pass the extra CFLAGS and LDFLAGS directly to
> make it work. correct?

or use the appropriate tool for getting CFLAGS/LDFLAGS instead of:
1. hardcoding it and potentially get them wrong
2. expecting the user will have to take extra steps, while he can just run make

> Regards
>
> Bamvor
>>
>>> cheers
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-kselftest" 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] 8+ messages in thread

* Re: [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS
  2017-06-29 11:39   ` Fathi Boudra
  2017-06-30  2:20     ` Bamvor Zhang Jian
@ 2017-06-30 11:01     ` Michael Ellerman
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2017-06-30 11:01 UTC (permalink / raw)
  To: Fathi Boudra; +Cc: linux-kselftest, Shuah Khan, linux-kernel, Bamvor Jian Zhang

Fathi Boudra <fathi.boudra@linaro.org> writes:

> On 29 June 2017 at 12:01, Michael Ellerman <mpe@ellerman.id.au> wrote:
>> Fathi Boudra <fathi.boudra@linaro.org> writes:
>>
>>> Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
>>> figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.
>>
>> Can you explain how it fixes the values for cross-compilation?
>
> When pkg-config is invoked in a cross-build environment, it will
> return your sysroot headers path instead of the hardcoded
> -I/usr/include/libmount
>
> For example in my oe environment, when I invoke "pkg-config --cflags
> mount", it returns:
> -I/build/tmp-rpb-glibc/sysroots/hikey/usr/include/libmount

Right, presumably because OE is setting PKG_CONFIG_SYSROOT_DIR etc.

So for folks doing it by hand it doesn't really help with cross
compiling, but I guess it doesn't hurt either.

cheers

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

* Re: [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS
  2017-06-30  5:53       ` Fathi Boudra
@ 2017-07-01  1:48         ` Michael Ellerman
  2017-07-03 11:23           ` Fathi Boudra
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Ellerman @ 2017-07-01  1:48 UTC (permalink / raw)
  To: Fathi Boudra, Bamvor Zhang Jian; +Cc: linux-kselftest, Shuah Khan, linux-kernel

Fathi Boudra <fathi.boudra@linaro.org> writes:

> On 30 June 2017 at 05:20, Bamvor Zhang Jian <bamvor.zhangjian@linaro.org> wrote:
>> On 29 June 2017 at 19:39, Fathi Boudra <fathi.boudra@linaro.org> wrote:
>>> On 29 June 2017 at 12:01, Michael Ellerman <mpe@ellerman.id.au> wrote:
>>>> Fathi Boudra <fathi.boudra@linaro.org> writes:
>>>>
>>>>> Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
>>>>> figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.
>>>>
>>>> Can you explain how it fixes the values for cross-compilation?
>>>
>>> When pkg-config is invoked in a cross-build environment, it will
>>> return your sysroot headers path instead of the hardcoded
>>> -I/usr/include/libmount
>>>
>>> For example in my oe environment, when I invoke "pkg-config --cflags
>>> mount", it returns:
>>> -I/build/tmp-rpb-glibc/sysroots/hikey/usr/include/libmount
>> I suppose we could also pass the extra CFLAGS and LDFLAGS directly to
>> make it work. correct?
>
> or use the appropriate tool for getting CFLAGS/LDFLAGS instead of:
> 1. hardcoding it and potentially get them wrong
> 2. expecting the user will have to take extra steps, while he can just run make

Sure. But by using the "appropriate tool" you create a new dependency on
that tool.

For folks building natively it's probably not a big deal, they probably
already have pkg-config installed, but for cross building it's another
thing to get working.

Currently most of the selftests build, and cross-build, with nothing but
a C compiler and libc, and we should try to maintain that as much as
possible.

cheers

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

* Re: [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS
  2017-07-01  1:48         ` Michael Ellerman
@ 2017-07-03 11:23           ` Fathi Boudra
  0 siblings, 0 replies; 8+ messages in thread
From: Fathi Boudra @ 2017-07-03 11:23 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Bamvor Zhang Jian, linux-kselftest, Shuah Khan, linux-kernel

On 1 July 2017 at 04:48, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Fathi Boudra <fathi.boudra@linaro.org> writes:
>
>> On 30 June 2017 at 05:20, Bamvor Zhang Jian <bamvor.zhangjian@linaro.org> wrote:
>>> On 29 June 2017 at 19:39, Fathi Boudra <fathi.boudra@linaro.org> wrote:
>>>> On 29 June 2017 at 12:01, Michael Ellerman <mpe@ellerman.id.au> wrote:
>>>>> Fathi Boudra <fathi.boudra@linaro.org> writes:
>>>>>
>>>>>> Fix hardcoded and misplaced libmount headers. Use pkg-config instead to
>>>>>> figure out CFLAGS/LDLIBS, fixing also their value for cross-compilation.
>>>>>
>>>>> Can you explain how it fixes the values for cross-compilation?
>>>>
>>>> When pkg-config is invoked in a cross-build environment, it will
>>>> return your sysroot headers path instead of the hardcoded
>>>> -I/usr/include/libmount
>>>>
>>>> For example in my oe environment, when I invoke "pkg-config --cflags
>>>> mount", it returns:
>>>> -I/build/tmp-rpb-glibc/sysroots/hikey/usr/include/libmount
>>> I suppose we could also pass the extra CFLAGS and LDFLAGS directly to
>>> make it work. correct?
>>
>> or use the appropriate tool for getting CFLAGS/LDFLAGS instead of:
>> 1. hardcoding it and potentially get them wrong
>> 2. expecting the user will have to take extra steps, while he can just run make
>
> Sure. But by using the "appropriate tool" you create a new dependency on
> that tool.
>
> For folks building natively it's probably not a big deal, they probably
> already have pkg-config installed, but for cross building it's another
> thing to get working.
>
> Currently most of the selftests build, and cross-build, with nothing but
> a C compiler and libc, and we should try to maintain that as much as
> possible.

As you said, most of selftests build. There's a precedent. memfd test
is also using pkg-config. That's why I followed similar approach.

> cheers
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kselftest" 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] 8+ messages in thread

end of thread, other threads:[~2017-07-03 11:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29  6:58 [PATCH 1/1] selftests: gpio: use pkg-config to determine libmount CFLAGS/LDLIBS Fathi Boudra
2017-06-29  9:01 ` Michael Ellerman
2017-06-29 11:39   ` Fathi Boudra
2017-06-30  2:20     ` Bamvor Zhang Jian
2017-06-30  5:53       ` Fathi Boudra
2017-07-01  1:48         ` Michael Ellerman
2017-07-03 11:23           ` Fathi Boudra
2017-06-30 11:01     ` Michael Ellerman

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