[FFmpeg-devel] [PATCH 1/3] configure: improve pkg-config support

Reinhard Tartler siretart
Sun Mar 6 20:33:45 CET 2011


On Sun, Mar 06, 2011 at 17:33:56 (CET), M?ns Rullg?rd wrote:

> Reinhard Tartler <siretart at tauware.de> writes:
>
>> On Sun, Mar 06, 2011 at 14:57:52 (CET), Mans Rullgard wrote:
>>
>>> This adds helper functions for checking packages with pkg-config
>>> and managing the associated flags.
>>>
>>> Note that pkg-config use is still discouraged due to widespread
>>> poor practices resulting in broken flags in many situations.  A
>>> few badly designed packages require flags only obtainable using
>>> pkg-config, and these functions are intended for those cases.
>>>
>>> Signed-off-by: Mans Rullgard <mans at mansr.com>
>>> ---
>>>  configure |   36 +++++++++++++++++++++++++++++++++++-
>>>  1 files changed, 35 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/configure b/configure
>>> index 7cb0410..b58c291 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -356,6 +356,16 @@ set_weak(){
>>>      done
>>>  }
>>>  
>>> +set_safe(){
>>> +    var=$1
>>> +    shift
>>> +    eval $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')='$*'
>>> +}
>>> +
>>> +get_safe(){
>>> +    eval echo \$$(echo "$1" | sed 's/[^A-Za-z0-9_]/_/g')
>>> +}
>>> +
>>
>> I wonder what was the motivation for these two functions. can you please
>> give an example for what cases (packages) they are necessary?
>
> Consider the package name gtk+-2.0.

Right, now I see it. A comment like 'e.g., gtk+-2.0 -> gtk__2.0' would
have helped, I guess.

>>>  pushvar(){
>>>      for var in $*; do
>>>          eval level=\${${var}_level:=0}
>>> @@ -744,6 +754,20 @@ check_lib2(){
>>>      check_func_headers "$headers" $func "$@" && add_extralibs "$@"
>>>  }
>>>  
>>> +check_pkg_config(){
>>> +    log check_pkg_config "$@"
>>> +    pkg="$1"
>>> +    headers="$2"
>>> +    func="$3"
>>> +    shift 3
>>> +    $pkg_config --exists $pkg || return
>>> +    pkg_cflags=$($pkg_config --cflags $pkg)
>>> +    pkg_libs=$($pkg_config --libs $pkg)
>>> +    check_func_headers "$headers" $func $pkg_cflags $pkg_libs "$@" &&
>>> +        set_safe ${pkg}_cflags $pkg_cflags   &&
>>> +        set_safe ${pkg}_libs   $pkg_libs
>>> +}
>>> +
>>
>> I understand your deep distrust in pkg-config, but additionally checking
>> for missing headers here just checks for 'correctness' of pkg-config
>> files. I think we can and should rely that existing .pc files are not
>> broken and if we encouter broken ones, report them to upstreams and
>> distros. This additional check feels like overdoing that to me.
>>
>> Or do I miss some important point here?
>
> I've seen pkg-config fail often enough not to trust it without an extra
> check. 

AFAIUI, this are bugs in .pc files, not pkg-config per se. .pc files are
much easier to fix.

> Common failure modes include reporting packages on the host
> system rather a cross-target and requesting flags incompatible with
> non-gcc compilers.  This check will catch both of those.  Otherwise
> cross-builds will incorrectly report e.g. SDL as present and fail during
> the build, the very situation Stefano sought to avoid.

is sdl upstream that indifferent to not bother accepting a fix for their
.pc files?

-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4




More information about the ffmpeg-devel mailing list