build: add -lsocket -lnsl if needed on illumos and older Solaris

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
Alan Coopersmith 2025-08-16 15:32:18 -07:00 committed by Simon McVittie
parent 095c199e04
commit 4c300d40cd
2 changed files with 22 additions and 0 deletions

View file

@ -685,6 +685,25 @@ foreach function : ['socket', 'socketpair']
endif
endforeach
# getsockname(), getpeername() might be in -lnsl, for example on older Solaris
foreach function : ['getsockname', 'getpeername']
if not cc.has_function(
function,
args: compile_args_c,
dependencies: network_libs,
)
nsl_lib = cc.find_library('nsl', required: false)
if nsl_lib.found() and cc.has_function(
function,
args: compile_args_c,
dependencies: network_libs + [nsl_lib],
)
network_libs += [nsl_lib]
break
endif
endif
endforeach
if get_option('x11_autolaunch').disabled()
use_x11_autolaunch = false
x11 = not_found

View file

@ -23,6 +23,7 @@ if not platform_windows
dbus_cleanup_sockets = executable('dbus-cleanup-sockets',
'dbus-cleanup-sockets.c',
include_directories: root_include,
dependencies: network_libs,
install: true,
)
endif
@ -54,6 +55,7 @@ dbus_monitor = executable('dbus-monitor',
'dbus-monitor.c',
'tool-common.c',
include_directories: root_include,
dependencies: network_libs,
link_with: libdbus,
install: true,
)
@ -73,6 +75,7 @@ dbus_send = executable('dbus-send',
'dbus-send.c',
'tool-common.c',
include_directories: root_include,
dependencies: network_libs,
link_with: libdbus,
install: true,
)