tests: Fix pointer type for assert_string_equal()
[resolv_wrapper.git] / ConfigureChecks.cmake
index 4752cd441233e90219215f36e55e6baea85c62f3..6eb00daabc72fc5681ecc1c3b564cff36853ddd9 100644 (file)
@@ -57,12 +57,23 @@ check_function_exists(getexecname HAVE_GETEXECNAME)
 
 find_library(RESOLV_LIRBRARY resolv)
 if (RESOLV_LIRBRARY)
-    set(HAVE_LIBRESOLV TRUE)
+    check_function_exists(res_nquery HAVE_LIBC_RES_INIT)
+    check_function_exists(__res_query HAVE_LIBC__RES_INIT)
+
+    if (NOT HAVE_LIBC_RES_INIT AND NOT HAVE_LIBC__RES_INIT)
+        set(CMAKE_REQUIRED_LIBRARIES ${RESOLV_LIRBRARY})
+        check_function_exists(res_query HAVE_RES_QUERY)
+        check_function_exists(__res_query HAVE___RES_QUERY)
+        unset(CMAKE_REQUIRED_LIBRARIES)
+
+        if (HAVE_RES_QUERY OR HAVE___RES_QUERY)
+            set(HAVE_LIBRESOLV 1)
+
+        endif()
+    endif()
 
     # If we have a libresolv, we need to check functions linking the library
     list(APPEND _REQUIRED_LIBRARIES ${RESOLV_LIRBRARY})
-else()
-    message(STATUS "libresolv not found on ${CMAKE_SYSTEM_NAME}: Only dns faking will be available")
 endif()
 
 set(CMAKE_REQUIRED_LIBRARIES ${RESOLV_LIRBRARY})
@@ -176,6 +187,12 @@ int main(void) {
 check_struct_has_member("struct __res_state" _u._ext.nsaddrs
                         "sys/socket.h;netinet/in.h;resolv.h"
                         HAVE_RES_STATE_U_EXT_NSADDRS)
+check_struct_has_member("union res_sockaddr_union" sin
+                        "sys/socket.h;netinet/in.h;resolv.h"
+                        HAVE_RES_SOCKADDR_UNION_SIN)
+check_struct_has_member("union res_sockaddr_union" sin6
+                        "sys/socket.h;netinet/in.h;resolv.h"
+                        HAVE_RES_SOCKADDR_UNION_SIN6)
 
 check_c_source_compiles("
 void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
@@ -199,4 +216,8 @@ int main(void) {
 # ENDIAN
 test_big_endian(WORDS_BIGENDIAN)
 
+if (NOT HAVE_LIBRESOLV)
+    message(STATUS "Limited features: Only dns faking will be available")
+endif()
+
 set(RWRAP_REQUIRED_LIBRARIES ${_REQUIRED_LIBRARIES} CACHE INTERNAL "resolv_wrapper required system libraries")