aboutsummaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-03-21 08:41:26 +0800
committerfanquake <fanquake@gmail.com>2021-03-29 11:09:40 +0800
commit879215e665a9f348c8d3fa92701c34065bc86a69 (patch)
treea95c1242569cc28f596a8e849eaad52573fedaf8 /build-aux
parent87deac66aa747481e6f34fc80599e1e490de3ea0 (diff)
downloadbitcoin-879215e665a9f348c8d3fa92701c34065bc86a69.tar.xz
build: check if -lsocket is required with *ifaddrs
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/m4/l_socket.m436
1 files changed, 36 insertions, 0 deletions
diff --git a/build-aux/m4/l_socket.m4 b/build-aux/m4/l_socket.m4
new file mode 100644
index 0000000000..38923a98fc
--- /dev/null
+++ b/build-aux/m4/l_socket.m4
@@ -0,0 +1,36 @@
+# Illumos/SmartOS requires linking with -lsocket if
+# using getifaddrs & freeifaddrs
+
+m4_define([_CHECK_SOCKET_testbody], [[
+ #include <sys/types.h>
+ #include <ifaddrs.h>
+
+ int main() {
+ struct ifaddrs *ifaddr;
+ getifaddrs(&ifaddr);
+ freeifaddrs(ifaddr);
+ }
+]])
+
+AC_DEFUN([CHECK_SOCKET], [
+
+ AC_LANG_PUSH(C++)
+
+ AC_MSG_CHECKING([whether ifaddrs funcs can be used without link library])
+
+ AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_SOCKET_testbody])],[
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_MSG_RESULT([no])
+ LIBS="$LIBS -lsocket"
+ AC_MSG_CHECKING([whether getifaddrs needs -lsocket])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_SOCKET_testbody])],[
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE([cannot figure out how to use getifaddrs])
+ ])
+ ])
+
+ AC_LANG_POP
+])