summaryrefslogtreecommitdiffstats
path: root/gl/m4/servent.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/servent.m4')
-rw-r--r--gl/m4/servent.m447
1 files changed, 47 insertions, 0 deletions
diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4
new file mode 100644
index 00000000..242f9e36
--- /dev/null
+++ b/gl/m4/servent.m4
@@ -0,0 +1,47 @@
1# servent.m4 serial 1
2dnl Copyright (C) 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SERVENT],
8[
9 dnl Where are getservent(), setservent(), endservent(), getservbyname(),
10 dnl getservbyport() defined?
11 dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(),
12 dnl getprotobynumber() defined?
13 dnl - On Solaris, they are in libsocket. Ignore libxnet.
14 dnl - On Haiku, they are in libnetwork.
15 dnl - On BeOS, they are in libnet.
16 dnl - On native Windows, they are in ws2_32.dll.
17 dnl - Otherwise they are in libc.
18 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
19 SERVENT_LIB=
20 gl_saved_libs="$LIBS"
21 AC_SEARCH_LIBS([getservbyname], [socket network net],
22 [if test "$ac_cv_search_getservbyname" != "none required"; then
23 SERVENT_LIB="$ac_cv_search_getservbyname"
24 fi])
25 LIBS="$gl_saved_libs"
26 if test -z "$SERVENT_LIB"; then
27 AC_CHECK_FUNCS([getservbyname], , [
28 AC_CACHE_CHECK([for getservbyname in winsock2.h and -lws2_32],
29 [gl_cv_w32_getservbyname],
30 [gl_cv_w32_getservbyname=no
31 gl_save_LIBS="$LIBS"
32 LIBS="$LIBS -lws2_32"
33 AC_TRY_LINK([
34#ifdef HAVE_WINSOCK2_H
35#include <winsock2.h>
36#endif
37#include <stddef.h>
38], [getservbyname(NULL,NULL);], [gl_cv_w32_getservbyname=yes])
39 LIBS="$gl_save_LIBS"
40 ])
41 if test "$gl_cv_w32_getservbyname" = "yes"; then
42 SERVENT_LIB="-lws2_32"
43 fi
44 ])
45 fi
46 AC_SUBST([SERVENT_LIB])
47])