trusteddomainproject / OpenDKIM

Other
97 stars 52 forks source link

configure.ac: configure script does not detect res_ninit correctly if resolv.h requires some other header files #203

Open futatuki opened 8 months ago

futatuki commented 8 months ago

On FreeBSD 14.0, after ./configure, ./config.log shows:

...
configure:14284: checking for library containing res_ninit
configure:14310: cc -o conftest -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing    -Wl,-rpath,/usr/local/lib -fstack-protector-strong  conftest.c  >&5
In file included from conftest.c:29:
/usr/include/resolv.h:158:14: error: array has incomplete element type 'struct sockaddr_in'
                nsaddr_list[MAXNS];     /*%< address of name server */
                           ^
/usr/include/resolv.h:157:9: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in
               ^
/usr/include/resolv.h:172:18: error: field has incomplete type 'struct in_addr'
                struct in_addr  addr;
                                ^
/usr/include/resolv.h:172:10: note: forward declaration of 'struct in_addr'
                struct in_addr  addr;
                       ^
/usr/include/resolv.h:197:21: error: field has incomplete type 'struct sockaddr_in'
        struct sockaddr_in      sin;
                                ^
/usr/include/resolv.h:157:9: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in
               ^
3 errors generated.
configure:14310: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "OpenDKIM"
| #define PACKAGE_TARNAME "opendkim"
| #define PACKAGE_VERSION "2.11.0"
| #define PACKAGE_STRING "OpenDKIM 2.11.0"
| #define PACKAGE_BUGREPORT "bugs@opendkim.org"
| #define PACKAGE_URL ""
| #define PACKAGE "opendkim"
| #define VERSION "2.11.0"
| #define HAVE_STDIO_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_SYS_TIME_H 1
| #define STDC_HEADERS 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/"
| #define HAVE_PTHREAD_PRIO_INHERIT 1
| #define HAVE_PTHREAD 1
| #define HAVE_INET_PTON 1
| #define HAVE_INET_NTOP 1
| #define HAVE_GETADDRINFO 1
| /* end confdefs.h.  */
| #include <resolv.h>
| int
| main (void)
| {
| return res_ninit(NULL);
|   ;
|   return 0;
| }
...
configure:14465: checking for sys/types.h
configure:14465: result: yes
configure:14483: checking for netinet/in.h
configure:14483: result: yes
configure:14501: checking for arpa/nameser.h
configure:14501: result: yes
configure:14519: checking for netdb.h
configure:14519: result: yes
configure:14537: checking for resolv.h
configure:14537: result: yes
...

This is caused by the configure.ac line 110-113 where use resolv.h in check for res_ninit before checking headers required by resolv.h.

With glibc, resolv.h itself contains all declarations for the function, so it is not affected. However in all other platform which requires some other headers for using resolv.h but has res_ninit() function, the check would be failed.

Note: In FreeBSD, res_setservers() is also in libc as __res_setservers and res_setservers is a macro in resolv.h. So it is need the same technique in the case of res_ninit if we want to detect it. However there are PR #99 and issue #199 mentioned about res_setservers, so I don't think we don't need to fix in the case res_setservers.