Debian Codegraph @

m4/servent.m4

raw
1 # servent.m4
2 # serial 5
3 dnl Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 AC_DEFUN([gl_SERVENT],
10 [
11 dnl Where are getservent(), setservent(), endservent(), getservbyname(),
12 dnl getservbyport() defined?
13 dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(),
14 dnl getprotobynumber() defined?
15 dnl - On Solaris < 11.4, they are in libsocket. Ignore libxnet.
16 dnl - On Haiku, they are in libnetwork.
17 dnl - On BeOS, they are in libnet.
18 dnl - On native Windows, they are in ws2_32.dll.
19 dnl - Otherwise they are in libc.
20 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
21 SERVENT_LIB=
22 gl_saved_libs="$LIBS"
23 AC_SEARCH_LIBS([getservbyname], [socket network net],
24 [if test "$ac_cv_search_getservbyname" != "none required"; then
25 SERVENT_LIB="$ac_cv_search_getservbyname"
26 fi])
27 LIBS="$gl_saved_libs"
28 if test -z "$SERVENT_LIB"; then
29 AC_CHECK_FUNCS([getservbyname], , [
30 AC_CACHE_CHECK([for getservbyname in winsock2.h and -lws2_32],
31 [gl_cv_w32_getservbyname],
32 [gl_cv_w32_getservbyname=no
33 gl_saved_LIBS="$LIBS"
34 LIBS="$LIBS -lws2_32"
35 AC_LINK_IFELSE(
36 [AC_LANG_PROGRAM(
37 [[
38 #ifdef HAVE_WINSOCK2_H
39 #include <winsock2.h>
40 #endif
41 #include <stddef.h>
42 ]],
43 [[getservbyname(NULL,NULL);]])],
44 [gl_cv_w32_getservbyname=yes])
45 LIBS="$gl_saved_LIBS"
46 ])
47 if test "$gl_cv_w32_getservbyname" = "yes"; then
48 SERVENT_LIB="-lws2_32"
49 fi
50 ])
51 fi
52 AC_SUBST([SERVENT_LIB])
53 ])