[vlc-devel] [PATCH 2/4] contrib: detect the pkg-config variant to use when cross-compiling
Steve Lhomme
robux4 at ycbcr.xyz
Wed Mar 18 09:08:19 CET 2020
On 2020-03-17 17:47, Rémi Denis-Courmont wrote:
> Le tiistaina 17. maaliskuuta 2020, 18.19.57 EET Steve Lhomme a écrit :
>> And use it for all contribs detection and building.
>>
>> on Debian, the x86_64-w64-mingw32-pkg-config may exist and run but give an
>> error when actually trying to find a package because the package
>> architecture doesn't exist for that target. So we have to test it
>> thoroughly.
>>
>> If we revert to pkg-config when cross-compiling we also force the
>> PKG_CONFIG_LIBDIR, otherwise we leave it untouched as the system/environment
>> may provide more that we know.
>>
>> Both /usr/$(HOST)/lib/pkgconfig and /usr/lib/$(HOST)/pkgconfig variants
>> exist, at least on Debian.
>> ---
>> contrib/src/main.mak | 24 +++++++++++++++++++++---
>> 1 file changed, 21 insertions(+), 3 deletions(-)
>>
>> diff --git a/contrib/src/main.mak b/contrib/src/main.mak
>> index 94660b33540..73d23d0018f 100644
>> --- a/contrib/src/main.mak
>> +++ b/contrib/src/main.mak
>> @@ -90,6 +90,9 @@ endif
>> ifneq ($(findstring $(origin WINDRES),undefined default),)
>> WINDRES := windres
>> endif
>> +ifneq ($(findstring $(origin PKG_CONFIG),undefined default),)
>
> As pointed out in previous iteration, this looks like cargo cult.
We can use ?= to do the same. But it's also done for WINDRES which
doesn't seem to ever have an implicit value:
https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html#Implicit-Variables
I ran `make -p` and there's no PKG* or WINDRES, WIDL, STRIP, RANLIB.
Either on Linux or in Msys2.
So I'd rather keep it consistant with the surrounding code for now. If
this code is cleaned someday it will be part of it.
>> +PKG_CONFIG := pkg-config
>> +endif
>> else
>> ifneq ($(findstring $(origin CC),undefined default),)
>> CC := $(HOST)-gcc
>> @@ -115,6 +118,24 @@ endif
>> ifneq ($(findstring $(origin WINDRES),undefined default),)
>> WINDRES := $(HOST)-windres
>> endif
>> +
>> +ifneq ($(findstring $(origin PKG_CONFIG),undefined default),)
>
> Ditto.
>
>> +# On Debian x86_64-w64-mingw32-pkg-config exists, runs but returns an error
>> when checking packages +ifeq ($(shell unset PKG_CONFIG_LIBDIR;
>> $(HOST)-pkg-config --version 1>/dev/null 2>/dev/null || echo FAIL),)
>> +PKG_CONFIG := $(HOST)-pkg-config
>> +else
>> +# Use the regular pkg-config and set some PKG_CONFIG_LIBDIR ourselves
>> +PKG_CONFIG := pkg-config
>> +ifeq ($(findstring $(origin PKG_CONFIG_LIBDIR),undefined default),)
>
> And ditto.
If we assume that PKG_CONFIG can has a default value in Make then it's
logical to assume it has the matching configuration as well. So either
we use $(origin) for both or none at all. For consistency I'd rather
keep it as such for now. I don't think it's a big performance hit. It
should be cleaned the same way as other $(origin) calls which actually
have no known default values in Make.
>> +# an extra PKG_CONFIG_LIBDIR was provided, use it prioritarily
>> +PKG_CONFIG_LIBDIR :=
>> $(PKG_CONFIG_LIBDIR):/usr/$(HOST)/lib/pkgconfig:/usr/lib/$(HOST)/pkgconfig
>> +else
>> +PKG_CONFIG_LIBDIR := /usr/$(HOST)/lib/pkgconfig:/usr/lib/$(HOST)/pkgconfig
>> +endif
>> +export PKG_CONFIG_LIBDIR
>> +endif
>> +endif
>> +
>> endif
>>
>> ifdef HAVE_ANDROID
>> @@ -224,13 +245,10 @@ export ACLOCAL_AMFLAGS
>> # Tools #
>> #########
>>
>> -PKG_CONFIG ?= pkg-config
>> ifdef HAVE_CROSS_COMPILE
>> # This inhibits .pc file from within the cross-compilation toolchain
>> sysroot. # Hopefully, nobody ever needs that.
>> PKG_CONFIG_PATH := /usr/share/pkgconfig
>> -PKG_CONFIG_LIBDIR := /usr/$(HOST)/lib/pkgconfig:/usr/lib/$(HOST)/pkgconfig
>> -export PKG_CONFIG_LIBDIR
>> endif
>> PKG_CONFIG_PATH := $(PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)
>> ifeq ($(findstring mingw32,$(BUILD)),mingw32)
>
>
> --
> Реми Дёни-Курмон
> http://www.remlab.net/
>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list