[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to properly check for -lresolv and resolv.h
From: |
Dan Mahoney |
Subject: |
Re: How to properly check for -lresolv and resolv.h |
Date: |
Sun, 14 Mar 2021 15:46:30 -0700 |
(Sorry, originally sent this reply only to Zack. email is hard :) )
> On Mar 14, 2021, at 11:57 AM, Zack Weinberg <zackw@panix.com> wrote:
>
> On Sat, Mar 13, 2021 at 4:53 PM Dan Mahoney (Gushi)
> <danm@prime.gushi.org> wrote:
>>
>> Hey there,
>>
>> I've just quelled a bunch of obselscence warnings for 2.70/2.71 in
>> OpenDMARC, so now I'm looking at the rest of it.
>>
>> In our project, we're doing the following to detect if we need -lresolv
>> (bottom of mail).
> ...
>> So there seems to be a good way to quiesce the need for resolv.h but not
>> -lresolv. This feels disjoint. Am I missing something?
>
> There isn't a built-in macro for -lresolv/-lbind, but you could
> express MTR's construct more concisely with AC_SEARCH_LIBS:
>
> AC_HEADER_RESOLV
>
> AC_SEARCH_LIBS([res_query], [-lresolv -lbind], [],
> [AC_SEARCH_LIBS([__res_query], [-lresolv -lbind], [],
> [AC_MSG_ERROR([No resolver library found])])])
>
> AC_SEARCH_LIBS([dn_expand], [-lresolv -lbind], [],
> [AC_MSG_ERROR([No resolver library found])])
>
> And then you could follow that up with a single AC_COMPILE_IFELSE with
> the test program you're using today, to verify that everything you
> need is available.
I can’t find a simple way to get autoconf to easily detect something like:
I want res_mkquery, which doesn’t exist in libresolv. (What exists in
libresolv is __res_mkquery).
What points res_mkquery to __res_mkquery is a preprocessor #DEFINE macro in
resolv.h.
Autoconf gives you no builtin to resolve those macros to
their real function names. Or to detect them as though they’re functions with
AC_SEARCH_LIBS.
If there’s a way to simply include resolv.h and still use *just* macros without
doing an AC_COMPILE_IFELSE?
Another feature I’d like to see is:
“here’s all the resolver functions I use in my code (and maybe their
__versions because of the issue above), do I need libresolv for *any*
of them?" If so, define -lresolv”,
But without having to do the nested block above for each function.
-Dan