[njs] Added pkg-config-based libxml2 detection.

Alejandro Colomar alx.manpages at gmail.com
Tue Jan 31 10:40:15 UTC 2023


Hi Konstantin,

On 1/31/23 04:24, Konstantin Pavlov wrote:
>>> @@ -6,12 +6,8 @@ NJS_HAVE_LIBXML2=NO
>>>     if [ $NJS_LIBXML2 = YES ]; then
>>>       njs_found=no
>>> -
>>> -    njs_feature="libxml2"
>>>       njs_feature_name=NJS_HAVE_LIBXML2
>>>       njs_feature_run=no
>>> -    njs_feature_incs="/usr/include/libxml2"
>>> -    njs_feature_libs="-lxml2"
>>>       njs_feature_test="#include <libxml/parser.h>
>>>                         #include <libxml/tree.h>
>>>   @@ -22,7 +18,27 @@ if [ $NJS_LIBXML2 = YES ]; then
>>>                             xmlCleanupParser();
>>>                             return 0;
>>>                         }"
>>> -    . auto/feature
>>> +
>>> +
>>> +    if /bin/sh -c "(pkg-config libxml-2.0 --exists)" >> $NJS_AUTOCONF_ERR 
>>> 2>&1; then
>>> +
>>> +        # pkg-config
>>> +
>>> +        njs_feature="libxml2 via pkg-config"
>>> +        njs_feature_incs=`pkg-config libxml-2.0 --cflags | sed -n -e 's/.*-I 
>>> *\([^ ][^ ]*\).*/\1/p'`
>>
>> I think you want -‐cflags‐only‐I
>> I'm not sure if it has any portability issues to old versions of pkg-config 
>> maybe?
> 
> Do you mean so pkg-config only outputs -I/foo/bar but not any non-I parts of 
> cflags like -Dfoo if any?

Exactly :)

 From the pkgconf(1) manual page:

        -‐cflags, -‐cflags‐only‐I, -‐cflags‐only‐other
                Display  either  all CFLAGS, only -I CFLAGS or only CFLAGS that
                are not -I.

I checked that the pkg-config_0.29.orig.tar.gz tarball from Debian Stretch, 
which is as far back as I can go, already provides this flag, so I guess it's 
reasonable to use it.

<https://packages.debian.org/source/stretch/pkg-config>
<http://deb.debian.org/debian/pool/main/p/pkg-config/pkg-config_0.29.orig.tar.gz>

>  Maybe. Not sure it's a big deal though?

Well, it's not a very big deal, but simplifies the code.

Cheers,

Alex

-- 
<http://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20230131/dc723bc9/attachment.bin>


More information about the nginx-devel mailing list