Pārlūkot izejas kodu

configure: used better detection of some functions when cross-compiling

Evgeny Grin (Karlson2k) 3 gadi atpakaļ
vecāks
revīzija
2efc013917
1 mainītis faili ar 27 papildinājumiem un 52 dzēšanām
  1. 27 52
      configure.ac

+ 27 - 52
configure.ac

@@ -1750,29 +1750,11 @@ AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len,
 #endif
 #endif
    ])
    ])
 
 
-MHD_CHECK_FUNC([getsockname],
-  [[
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-  ]],
-  [
-    struct sockaddr_storage ss;
-    (void)getsockname(socket(0,0,0),(struct sockaddr *)&ss,(void*)0);
-  ],
+MHD_CHECK_LINK_RUN([[for working getsockname()]],[[mhd_cv_getsockname_usable]],
+  [[mhd_cv_getsockname_usable='assuming yes']],
   [
   [
-    AC_CACHE_CHECK([[whether getsockname() is usable]], [[mhd_cv_getsockname_usable]],
-      [
-         AC_RUN_IFELSE(
-           [
-            AC_LANG_SOURCE(
-             [[
+    AC_LANG_SOURCE(
+      [[
 #ifdef HAVE_SYS_TYPES_H
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #include <sys/types.h>
 #endif
 #endif
@@ -1853,18 +1835,10 @@ int main(void)
 #endif
 #endif
   return ret;
   return ret;
 }
 }
-             ]]
-            )
-           ],
-           [[mhd_cv_getsockname_usable='yes']],
-           [[mhd_cv_getsockname_usable='no']],
-           [[mhd_cv_getsockname_usable='assuming yes']]
-         )
-        ]
-      )
-    AS_VAR_IF([[mhd_cv_getsockname_usable]], [["no"]], [:],
-        [AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable `getsockname' function.])])
-  ]
+      ]]
+    )
+  ],
+  [AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable `getsockname' function.])]
 )
 )
 
 
 AC_CACHE_CHECK([for usable PAGESIZE macro], [mhd_cv_macro_pagesize_usable],
 AC_CACHE_CHECK([for usable PAGESIZE macro], [mhd_cv_macro_pagesize_usable],
@@ -2074,8 +2048,13 @@ AC_INCLUDES_DEFAULT
       use_itc='pipe'
       use_itc='pipe'
       enable_itc="$use_itc"
       enable_itc="$use_itc"
       AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread communication])
       AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread communication])
-      AC_CACHE_CHECK([[whether pipe2(2) is usable]], [[mhd_cv_pipe2_usable]], [
-        AC_RUN_IFELSE([
+      MHD_CHECK_LINK_RUN([[whether pipe2(2) is usable]],[[mhd_cv_pipe2_usable]],
+        [
+          # Cross-compiling
+          AS_CASE([${host_os}], [kfreebsd*-gnu], [[mhd_cv_pipe2_usable='assuming no']],
+            [[mhd_cv_pipe2_usable='assuming yes']])
+        ],
+        [
           AC_LANG_PROGRAM([
           AC_LANG_PROGRAM([
 AC_INCLUDES_DEFAULT
 AC_INCLUDES_DEFAULT
 #ifdef HAVE_FCNTL_H
 #ifdef HAVE_FCNTL_H
@@ -2084,22 +2063,18 @@ AC_INCLUDES_DEFAULT
 #ifdef HAVE_UNISTD_H
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #include <unistd.h>
 #endif
 #endif
-          ], [[
-            int arr[2];
-            int res;
-            res = pipe2(arr, O_CLOEXEC | O_NONBLOCK);
-            if (res != 0) return 33;
-            close (arr[0]);
-            close (arr[1]);
-          ]])
-        ], [[mhd_cv_pipe2_usable='yes']], [[mhd_cv_pipe2_usable='no']], [
-          # Cross-compiling
-          AS_CASE([${host_os}], [kfreebsd*-gnu], [[mhd_cv_pipe2_usable='assuming no']],
-            [[mhd_cv_pipe2_usable='assuming yes']])
-        ])
-      ])
-      AS_CASE([["X-${mhd_cv_pipe2_usable}"]], [[X*yes]],
-        [AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable pipe2(2) function])])
+            ], [[
+              int arr[2];
+              int res;
+              res = pipe2(arr, O_CLOEXEC | O_NONBLOCK);
+              if (res != 0) return 33;
+              close (arr[0]);
+              close (arr[1]);
+            ]]
+          )
+        ],
+        [AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable pipe2(2) function])]
+      )
     ], [
     ], [
       AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])])
       AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])])
     ])
     ])